Seems like a dumb question, but I would like to make my game object falls as soon as it reaches the max height, instead flying “horizontally” at max height, when the force is applied.
This is my codes:
FixedUpdate() {
if (transform.position.y >= maxHeight) {
transform.position = new Vector2 (transform.position.x, maxHeight);
spirit.GetComponent<Rigidbody2D> ().AddForce (new Vector2(0, -60));
}
}
The force is seemed “never” applied to it.
If I removed
transform.position = new Vector2 (transform.position.x, spirit.maxHeight);
It would fly over the maximum height.
How to make the game object falls immediately when it reaches the maximum height?