# Need advice/ideas to construct an underwater zone

I need some advice/ideas on how to achieve a believable water zone - so that if an actor walks into the water, I can animate the actor to be swimming and if the camera is under the water plane, add a blueish caustic effect to the view. Any ideas on how I could begin to hammer this out?

May be this post is useful to you also.
discourse.panda3d.org/viewtopic.php?t=6255

You bet , your work on your virtual aquarium definitely has already been guiding me towards setting up some effects.

However, the first problem I need to solve is to somehow tag the water area, possibly using a tag on the water plane itself, and then making any area that is below the water plane Z axis a water environment, and adding the effects once an actor is below the surface a certain amount. I am trying to figure out how to use an x y z variable from my water plane to bound this water zone, but I haven’t quite enough to go on yet to start it.

hmm…I don’t get your problem. I saw your game shall have water shader with a terrain. If your actor’s eye level + terrain height < water level, then you shall under water already, isn’t it ?

Yes it does go below the water plane, but it isnt tagged as “underwater” in any way so I can use it as a variable or game state.

I am hoping to tag the water level and below as a zone of a sort, so that once a player wades into the water I can change the animation to swimming, and use that to add caustics and blueish tint to give the appearance that the actor is swimming in water, and when the actor swims to shore and gets out, return the animation and camera back to the normal state.

I know panda has built in FSM(Finite State Machine), which may be able to help you. Check the manual. I know FSMs are good for AI, but they are good for anything that has several varying states, like in your case where one state is swimming, one state is walking/running. You could also have states that transition between those two, and the manual explains how to use it.

Thank you for that, yes finite state machine is the way I will create this system, however the real problem is defining the water area itself, so I can call the FSM with its commands to change (fsm.request). How could I define the water area to begin? I may have to resort to something like

If actorZ < waterplaneZ then request fsm swimming.

The only problem with this is that then the x and y isn’t defined, so an actor could swim outside the bounds of the plane on those axis. I will try some calculations today and see what I can come up with.

Are you doing collision with the terrain somehow or other? If so, than you should still be doing it while swimming as well. While under water though, the collision response will be a little different, because you are swimming, but if you swim to the bottom, can you walk on the bottom?? If so, you need to have another FSM state. I don’t see how you could swim out of bounds though if you have terrain under the water as well and are doing the collisions. I think you are right though that you can detect the FSM change just checking the Z values.