enemy in the viewport

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

enemy in the viewport

Post by anjay »

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?
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4

Post by tuan kuranes »

you could use some isvisible() method on your node containing the ennemy

it won't attack you if you're in the same room...
But your IA should be aware that there is a wall using a precomputed visibility map.
Look tha AI paper links on the ogre Wiki Web links about how to do that sort of thing...
User avatar
litobyte
Halfling
Posts: 64
Joined: Mon Mar 28, 2005 7:03 pm
Location: Somewhere in Italy

Post by litobyte »

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.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Re: enemy in the viewport

Post by :wumpus: »

anjay 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..
This wouldn't work; you could sneak past every enemy by walking toward him backwards :-)
IF YOU DON'T SEE THE FNORD IT CAN'T EAT YOU, DON'T SEE THE FNORD, DON'T SEE THE FNORD
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

Post by anjay »

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.
User avatar
Bren
Goblin
Posts: 215
Joined: Tue Jul 08, 2003 4:41 pm
Location: 0,0,0

Re: enemy in the viewport

Post by Bren »

:wumpus: wrote:
anjay 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..
This wouldn't work; you could sneak past every enemy by walking toward him backwards :-)
IF YOU DON'T SEE THE FNORD IT CAN'T EAT YOU, DON'T SEE THE FNORD, DON'T SEE THE FNORD
http://hhgproject.org/entries/ravenousb ... beast.html
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

LOL! :-)
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4

Post by tuan kuranes »

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 !)
User avatar
regress
Halfling
Posts: 78
Joined: Sat Mar 26, 2005 8:39 pm

Post by regress »

heh, that's awesome. He blocked his view of the enemy soldiers or whatever those are with a bottle of pills, and so they couldn't see him.

For sure, they're some descendent of the revenous bugblatterbeast . . .

Funny the exploits people'll find!
regards