ODU
1
hello
everyone here I will wish to add a rotational force in my scripts but I do not know or add the “AddForce”
Thank you in advance for your response cordially
static var speed : float = 50.1;
var target : Transform;
function OnMouseDown () {
target.rigidbody.transform.Rotate(Vector3(0,speed,0));
}
You want Rigidbody.AddTorque():
For anyone that wanted to use the RigidBody2D version. Here’s what worked for me
“360” is a float. You can use whatever you wish.
GetComponent<Rigidbody2D>().AddTorque(360, ForceMode2D.Impulse);
Its a nice 1-2 punch with AddForce
GetComponent<Rigidbody2D>().AddForce(transform.up * 800);
Hope this helps others.