- Home /
Specific question about underwater physics (2D)
NOTE: my question pertains to Unity 2D
I am a fairly novice Unity developer, and I was wondering how to go about creating a space in which the 'character' in my platformer would experience a different set of physical laws (in this case, the player would accelerate much more slowly, and be nearly unaffected by gravity). However, I'm more interested in the general concept... for example, what about the opposite? I might also want to create an area where, for example, random forces (wind?) lift my character up, or throw him around?
^^^ all of that is just background. my question is, how do I create a field in which the physical properties of my character are altered??? One in which I can just check on my script "okay, are we in the field or not? If so, I'm going to do this..."
Answer by Owen-Reynolds · Jan 31, 2015 at 05:29 PM
Why did you write "specific" in the title? This question isn't specific at all!
Just look at general rigidbody settings and movement scripts. You can change game gravity in code. Can change move speed in the movement script. Can change how the player "coasts" in rigidbody settings. Can push a player around using AddForce.
It depends on the exact set-up you have. Just make anything to move the player. Then mess around with settings to make it feel more "underwatery" or "fly-ee." Write them down, and figure out how to switch them as you need to.
Thanks for the response Owen. I've edited my question and I hope that makes the information I'm looking for a bit clearer. I know how to make a character, as you put it, "fly-ee" or "underwatery". $$anonymous$$y issue is with the transition, and I can't use a collider as a trigger (because the character must be able to pass through this field, just as it would through water or air.
Ahh...read/play with triggers some more. They are known as volumes in other game engines. You can pass through them. The only thing they do is fire OnTrigger* events.
Your answer
Follow this Question
Related Questions
How to make 2D water like in Celeste 0 Answers
Pixel Perfect 2D Polygon Collider 2 Answers
Weird physics issue after disabling and re-enabling player gameobject. 3 Answers
SpriteRenderer stops receiving light 0 Answers
2D snow plowing game physics challenge 2 Answers