- Home /
How do I get my water to work?,How do I slow my descent in water?
I want my 2d platformer to have water physics that slow my descent and increase my jump. I set my water to a trigger and coded in my player movement that if it's in the water area, then set the gravity lower. The issue is, I can't figure out how to detect when I leave the water, so I can't change the gravity back! please give me the answer I need!,I want to make the water in my game slow my decent and boost my jump. I have made the code so that it changes my Rigidbody's gravity when I enter the water, but I can't figure out how to change gravity back after leaving the water! If you need clarification in order to answer, the game is in 2D.
If your character uses a rigidbody controller, then you dont need reference to the player. Just add a force upward to any collider within the trigger (`OnTriggerStay`). For example:
void OnTriggerStay(Collision collider)
{
collider.attachedRigidbody.AddForce(Vector3.up * Buoyancy);
}
Your answer
Follow this Question
Related Questions
Trigger gravity by external collider 2 Answers
No gravity when running against a wall (2D) 1 Answer
Making Sprite Disappear on Trigger 2 Answers
Trigger with Gravity + Collision 2 Answers
Low gravity on trigger. 2 Answers