Game Development Community

Water and NPC.

by foribiteu · in Torque 3D Professional · 02/16/2012 (11:36 pm) · 3 replies

Two questions that in a way are the same:

1) Is there a good way to keep NPC from wondering off into the water with out making sure they can not reach the water.

2) Fish, how to keep them in the Water.

Have not looked to much at this yet, just wondering if any one tried it.

#1
02/21/2012 (9:36 am)
I do believe for keeping NPC's out of the water you can take a look at either a containerRadiusSearch/containerRaycast using the water as a target. Or simply program their AI to function as so they stay out of the water.

As for keeping things in the water, you might want to program a water check of some form to see if an object is inside a water block. Then do a containerRaycast to check for the terrain to see if it's touching the land by a factor of some distance.

Hope this helps!
#2
02/22/2012 (6:55 am)
In scripts/server/player.cs there is an Armor::onEnterLiquid() callback that you might be able to leverage for your NPCs. As for the fish, just give them legs so they don't look so odd on land.

Actually, you could put a collision shape over your water and set a name on it so that your fish can collide and you can have other objects ignore it. Or use a trigger and kick the fish back in onLeaveTrigger(). That one's probably easier.
#3
03/06/2012 (10:52 pm)
I will have to take a look at that. There is a lot of water in my level and I do plan on having some mean fish out there.