Hi, I’ve been trying to fix my problem for quite some time and I still can’t so I hope someone here will be able to.
I’ve go a falling Rigidbody2D (without velocity at start), with y positive :
void Start()
{
rigidbody2d = transform.GetComponent<Rigidbody2D>();
}
When reaching y = 0, I want it to “rebound” (in thin air), for that, I only invert the velocity.y :
private void Update()
{
if (rigidbody2d.position.y < 0f && rigidbody2d.velocity.y < 0f)
{
rigidbody2d.velocity = -Vector2.up*rigidbody2d.velocity.y;
}
}
My object shouldn’t lose energy at all because I’ve set all drags to 0. However, rebound after rebound, the objet goes less and less high.
I’d like it to be able to bounce at the same high every time. Obviously, FixedUpdate gives the same result.
If anyone knows what’s causing that effect and correct it, please tell me!
Thanks in advance