Im currently working on fps AI but im not sure how to make the AI have a field of vision, like if your behind something, but your in his attack range, he wont attack because he cant see you. Does anyone know who to achieve this?
I think what you can do is rig your charatcer, animatimate it, ect, that make sure it’s pointing on a perfect angle, for example he’s perfectly on the Y axis or X axis. That make a Ray Sensor and make it point to the front of your character. Then he won’t notice you when your behind him/her.
Yer, but if your behind say, a wall. He’ll attack. I want him to attack only if theres nothing between you and the enemy.
If you don’t use the X-Ray Option (see through objects that don’t have the property) the enemy won’t see the player behind a wall.
Give a “player” property to your player.
And use the “player” property on the ray sensor attached to the enemy.
Then you will have to switch his behavior that way :
- the enemy is patrolling
- he can see you, he attacks
- he can’t? he stops attacking and you have two choices :
- he patrols again (back to the first state)
- he stops attacking (shooting) but he is still tracking you and finds a way to reach you
Could be hard using rays, youd have to use multiple rays.
If you get the position of the player and the position of the bot and work out the angle from the front of the bot the player and if thats +/- 30 then the player is infront of the bot.
then cast a ray to the player from the bot, if it returns true the bot can see the player.
thx, but im not to good at python, ill just stick to just the ray sensor