PDA

View Full Version : How to handle water



mikael
05-07-2008, 07:30 AM
I was wondering how to handle something like water correctly. Where if someone tried to walk across it they should be stopped so it has to have collision data but at the same time an enemy should be able to look across it and see the player.

I had something like this scenario in mind:
The player and an enemy is separated by a small river and there's a bridge a bit further down. The enemy should be able to see the player but recognise that it can't reach him and so try to use checkpoints to navigate across the bridge first.
So HasLineOfSightToPosition should return true for the enemy but CanWalkTo should return false. Currently they would both return false since the water texture would have collision data and I don't know how to make it transparent without using SetIsCreature. And that feels a bit like cheating, plus I think a lot of other AI behaviour would be difficult to implement if it was considered a creature.
Also according to the scripting reference, CanWalkTo and HasLineOfSightToPosition are both the same function internally at the moment.

Is there some way to solve this?

Seth
05-07-2008, 11:11 PM
Good questions.

I'll probably add a new material type, similar to how C_MATERIAL_TYPE_VERTICAL_LADDER is added and checked for ladders in the treeworld example.

The ladder stuff is done 100% in script, but for this, the engine will have to respect it in places as well.. also we'll need a "GetDistanceToEntityByWalk()" or something so the AI can understand when an entity is 2 feet away but 1000 feet away if they try to walk to it due to bridges and such. (CanWalk isn't really enough info)

But what is a good name for a material type to be used as a water, cliff boundary? Hrm.

I'm going to add projectile weapons to the RPG example, and some water to shoot over. Maybe also a boat you can buy to traverse water...

mikael
05-08-2008, 07:03 PM
Maybe call it something like transparent_boundary or translucent_obstacle? Considering it could also be used for other solid-but-see-through objects like glass or fences.

Seth
05-08-2008, 11:15 PM
Good point - I didn't think about transparent but non-passable-for projectiles.. so maybe we need:

Water (can't walk on (without boat), can shoot over, can see over)
Transparent (can't walk on, can't shoot over, can see over)
Cliff (can't walk on, can shoot over, can see over)

Water and cliff are basically the same, but it would be helpful for scripters to know the difference so we can have boats behave right.