there are some enemies in my scene which can shoot. I want that they start shooting only when they are near to the character which I manipulate. first I took up the distance between enemy and my character and when it lower that particular, enemy starts to react. but this is not good when player is in one room and enemy in another, beyond the wall.
maybe the solution could be that enemy start to react when it is in the viewport of the camera (camera's position is always some units behind the player)? but I do not know how to check this..
or you could suggest another solution to this?
enemy in the viewport
-
- Gnoblar
- Posts: 9
- Joined: Thu Mar 17, 2005 3:29 pm
- Location: Vilnius, Lithuania
-
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
-
- Halfling
- Posts: 64
- Joined: Mon Mar 28, 2005 7:03 pm
- Location: Somewhere in Italy
Precalculating visibility is always good.
But if you have also dynamic objects eg: destructable geometry like cupboards tables or so that can limit the visibility of your AI then you should do it real time.
What about a quick "linepick" I don't know the name of the Ogre function.
Should be something with "Ray Query" or so..
You can then check if you have geometry occlusion among 2 xyz points.
But if you have also dynamic objects eg: destructable geometry like cupboards tables or so that can limit the visibility of your AI then you should do it real time.
What about a quick "linepick" I don't know the name of the Ogre function.
Should be something with "Ray Query" or so..
You can then check if you have geometry occlusion among 2 xyz points.
-
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
Re: enemy in the viewport
This wouldn't work; you could sneak past every enemy by walking toward him backwardsanjay wrote: maybe the solution could be that enemy start to react when it is in the viewport of the camera (camera's position is always some units behind the player)? but I do not know how to check this..

IF YOU DON'T SEE THE FNORD IT CAN'T EAT YOU, DON'T SEE THE FNORD, DON'T SEE THE FNORD
-
- Gnoblar
- Posts: 9
- Joined: Thu Mar 17, 2005 3:29 pm
- Location: Vilnius, Lithuania
what do you mean by 'precalculating visibility'? I can not imagine how this works.. I understand, that I have to have some method isVisible(), but I do not know how to implement it..
raySceneQuery, actually it is possible to use it, I can emit the ray directly forward and check if it intersects with enemy. it is good, when enemy is opposite me, but if it is to the right of me, then it start to react only when I turn to him.. okay, I will try with this. I also will look at wiki on AI.
raySceneQuery, actually it is possible to use it, I can emit the ray directly forward and check if it intersects with enemy. it is good, when enemy is opposite me, but if it is to the right of me, then it start to react only when I turn to him.. okay, I will try with this. I also will look at wiki on AI.
-
- Goblin
- Posts: 215
- Joined: Tue Jul 08, 2003 4:41 pm
- Location: 0,0,0
Re: enemy in the viewport
http://hhgproject.org/entries/ravenousb ... beast.html:wumpus: wrote:This wouldn't work; you could sneak past every enemy by walking toward him backwardsanjay wrote: maybe the solution could be that enemy start to react when it is in the viewport of the camera (camera's position is always some units behind the player)? but I do not know how to check this..
IF YOU DON'T SEE THE FNORD IT CAN'T EAT YOU, DON'T SEE THE FNORD, DON'T SEE THE FNORD
-
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
-
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
You'll get the answers on the Wiki links.
But basically, using rays to get decent results is very, very cpu intensive, so 'precalculating visibility' is about launching rays from each point of a map to get an array of visible other points. Then in run-time, you can just read the array to determine visibility. (half-life 1 paper goes even farther end optimize that, you should read it (on the wiki))
If you do this run-time you'll have to use a reduced number of rays instead of cone of dense ray following the Field of Vision, you'll use ... says 1/2/4/8 rays...
but what if those are blocked by tiny objects : you'll get dumb IA...
That's what happened in Half-life 2, Download the video here to see that : http://www.nofrag.com/fichiers/halflife2/videos/937/
(That's near the towel on head thing !)
But basically, using rays to get decent results is very, very cpu intensive, so 'precalculating visibility' is about launching rays from each point of a map to get an array of visible other points. Then in run-time, you can just read the array to determine visibility. (half-life 1 paper goes even farther end optimize that, you should read it (on the wiki))
If you do this run-time you'll have to use a reduced number of rays instead of cone of dense ray following the Field of Vision, you'll use ... says 1/2/4/8 rays...
but what if those are blocked by tiny objects : you'll get dumb IA...
That's what happened in Half-life 2, Download the video here to see that : http://www.nofrag.com/fichiers/halflife2/videos/937/
(That's near the towel on head thing !)
-
- Halfling
- Posts: 78
- Joined: Sat Mar 26, 2005 8:39 pm