I’m mocking up a prototype of a physics based 2d controller for a flying character.
I have him gaining height in Y as I AddForce on a Input.GetKeyDown. Pretty simple stuff (even for me).
What I’m not sure how to approach is having him maintain altitude at a position.y after I release the InputGetKeyDown . Basically, he’s a bird-type character, (2D sidescroller, he flies up and down collecting various stuff). My thought is I need to pipe the current transform.position.y into a variable and then assign that to his new position. And never allow him to fly above a certain Y height, perhaps setting a maximum Y even if still applying a force up.
Any guidance would be appreciated. Thanks and have a great weekend.
B.