- Home /
2D water script, player in water physics
Well I don't know how to start with creating water in my 2D game, I did transparent sprite with box collider 2D isTrigger, and I tried to change gravity when my character will be in water, but it's not working like i want. I want to create water like that (only to 16 second). https://www.youtube.com/watch?v=JF9gYfRTuyo
I suppose you were sort off on the right track, make the colliders triggers and when you are on collision you simply apply different gravity indeed, but you can use the player controller to apply some velocity to him to go up when spacebar is pressed, you just need to play around with the rigidbody I believe, maybe lower the mass.
Answer by a161803398874 · Aug 02, 2017 at 10:16 AM
Put a collider on the water tiles, one that is triggable and that you can pass trhu, then add a tag to all these colliders called water...then in your movement script before moving you check to see if its on land or in water with the "OnTriggerEnter" method and compare them tags, if its on land play with default controller if its in water smooth all values from normal controller ,set them to half of the original value, including gravity"
Your answer
Follow this Question
Related Questions
Sprite image not changing 0 Answers
2D Balance 1 Answer
Collision/scripting for tiles 0 Answers
Need to restrict "air control" 2D platformer. 1 Answer
Adding jump animation in script editor [2D Project] 0 Answers