Just as the title suggests... is there a way to make it so that a character cannot walk in to or on to water in my scene?
I just want to make the areas where I have water off-limits.
asked Feb 25 '10 at 04:16 PM
If you're using the physics engine for general movement and control of the objects in your scene, you might want to make some invisible walls around your water areas.
Create the wall meshes as normal in your 3D app, then just make sure they have a Mesh Collider attached, marked as static, and disable the renderer component - making them invisible.
answered Feb 25 '10 at 04:30 PM
I'm going to play with your requirements a bit here, but this should be a LOT easier to implement. I'm a coder, so every time I hear "make a mesh in your 3d program" I look for a workaround...
Assuming that your water is all at a certain height, and the player never needs to go below that depth for any reason: Create a box collider the size of your bodies of water. Set it to Is Trigger. Lower it to the appropriate height.
Each frame your player is on the ground, check to see if he has a collision event with one of these water colliders. If he does not, remember his position. If he does, go back to that position and set his velocity to 0.
This approach should require little time to implement, as long as you dont frequently need to go below water level right next to the water.
answered Feb 27 '10 at 05:44 AM
use triggers. create box colliders and put them around your water surface. or create a big sphere collider and put it inside your water and make it bigger than your water surface. then in OnTriggerEnter of those triggers don't allow the player to go inside triggers.
answered Feb 27 '10 at 06:44 AM