Hi guys,
Miss AddRelativeForce for rigidbody2D.
Any idea of how to emulate it?
Thanks!
Hi guys,
Miss AddRelativeForce for rigidbody2D.
Any idea of how to emulate it?
Thanks!
You could transform the force direction into local direction with:
Vector3 relativeForce = transform.InverseTransformDirection(forceDirection);
rigidbody2d.AddForce(new Vector2(relativeForce.x, relativeForce.y));
Thanks :)
– OrzolaNo problem. =) If it works for you then please mark it as answered so your question gets removed from the unanswered section.
– GameVortexIt's working! But torque is inverted. I have added '-1 to x in new the vector. Vector3 relativeForce = transform.InverseTransformDirection(Vector3.up); rigidbody2D.AddForce(new Vector2(relativeForce.x * -1, relativeForce.y)) GameVortex, can't vote up. Don't have enough karma :'(
– Orzola