Jump to content

Calculating a Peek value for aiPlayer


Hodo33

Recommended Posts

I am trying to hide from my bots and peek around a corner to see them. If I use SetAimObject they will shoot me if one inch is exposed using the los test.

I tried getobjectBox and then getworldboxcenter and calculate a percent of exposure which does not seem to effective. Does anyone have a simple way to see how much I am exposed to bot line of sight tests?

Link to comment
Share on other sites

How did you even manage to get the bots to be that good? I thought the bots aim for the center of the target, which should make them not shoot you if you just peek.


Otherwise I would just solve it with some getRandom value, like a roleplaying game, so you have a probability the bot can see you and shoot you, probably no human player will detect that your "algorithm" for that is just a random value.

Link to comment
Share on other sites

%bot.setAimObject(%player)

%res = %bot.checkLosToObject(%player);

if(%res)

{

%bot.fire(true);

}


They shoot me through windows, door, at the edge of a building


right now to check los to object I use the boteye to playereye, if I change that to boteye to player worldboxcenter then I can stand in plain sight as long as half of my body is obscured which is also not realistic hence the question... thanks for the reply

Link to comment
Share on other sites

I don't even know what I use, all I know is they work fine. As an indie dev you have to learn how to be pragmatic, if it works good enough, don't bother with the details. You have to consider that if you change it, you may run into other problems, where the bot will not shoot a player even though for a human he is obviously visible, like you said with using worldboxcenter.


I would try to go with a simple workaround, like having a delay until the bot fires, like getRandom from 100ms to 2000ms , that way you do not notice when the bot sees you, since there is a random delay, or go the role play game route, where your visibility generates a percentage you get spottet, so if you are 20% visible, there is only a 20% change you get spotted, or some kind of algorithm, well really depends on the type of game.

Link to comment
Share on other sites

Thanks for the suggestions, I like the getRandom idea, allows me to look and hide a bit better.

The game is a RPG shooter. I want the player to be more tactical and have to consider their actions rather than run and gun. I set their seek field of view narrow until I shoot one or just get right in front of him, then set off a base alert and make them aware of me. I time out the alert and they revert to just hanging around.

Link to comment
Share on other sites

Then the RPG system would be ideal probably, the elder scrolls series originally had a skill system that would go from 0 to 100, which would be the percentage an action would succeed, where of course there were other factors taken into account as well, as well as a little bit random to spice up the gameplay.


I think there is a function in Torque3D which checks how much of an object is visible, since I knew I had to bother with it for a postFX to determine how much of the sun is visible, maybe you can use that to determine how much a player is visible and then apply some kind of 0-100% detection rate based on that.

Link to comment
Share on other sites

  • 2 months later...

%bot.setAimObject(%player)

%res = %bot.checkLosToObject(%player);

if(%res)

{

%bot.fire(true);

}


They shoot me through windows, door, at the edge of a building


right now to check los to object I use the boteye to playereye, if I change that to boteye to player worldboxcenter then I can stand in plain sight as long as half of my body is obscured which is also not realistic hence the question... thanks for the reply

 

Add a check for each shoulder visibility, this will become some more accurate.

Link to comment
Share on other sites

Expanding on Razer's idea, depending on how accurate you need the AI vision to be(obviously this is design dependent) one technique I've seen that better simulates sight/detection would be to randomly pick a point on the player's bounding box and fire a ray at it, instead of just their center.


If it hits, you add a small value to a detection bar(which degrades over time). This way you have the possibility of them spotting your foot or arm or whatnot, but it doesn't immediately make them go 'oh dang that's an enemy'


If you get a certain value on the 'detection' then they go into attack mode or whatnot, but because the value degrades, if they only get a glancing spot of you like your foot, they don't immediately attack.


This would be more relevent to something like a stealth game than a high-octane shooter.


If you need something simpler/more action oriented, then Duion's suggestion of random response delays or random detection chance would be pretty sufficient.

Link to comment
Share on other sites

I would suggest expanding the engine slightly as to allow you to easily get the transformed positions of nodes in the player mesh. I did this to approximate bullet collisions on players' limbs with really good success. In this way you can do ray casts to specific points on the animated skeleton (hand, elbow, knees, etc) to see if they're poking out of cover. I'm several engine iterations out of date now so I doubt my old code would be much use, but I'm sure you could poke around at how mount points are used as a jump start.

Link to comment
Share on other sites

I would suggest expanding the engine slightly as to allow you to easily get the transformed positions of nodes in the player mesh. I did this to approximate bullet collisions on players' limbs with really good success. In this way you can do ray casts to specific points on the animated skeleton (hand, elbow, knees, etc) to see if they're poking out of cover. I'm several engine iterations out of date now so I doubt my old code would be much use, but I'm sure you could poke around at how mount points are used as a jump start.

 

I think Steve posted a resource for getting the player node positions and transform, not long ago. Maybe it was in c++ subforum.

Link to comment
Share on other sites

Why should it not work anymore? If you want you can use it, I just don't know what the official source is with the latest updates, but it will not help with the aiPlayer peek value, it is just ragdolls. However it is part of the GMK kit, which meant game mechanics kit, which adds a lot of game mechanics you need for making a game, like cutscenes, scripted events and some ai features.


So before you bother creating any new feature, you should search through all the resources, since in many cases someone already programmed such a feature.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...