Answers for "how to add force to an object in unity3d"

C#
0

how to add a force to an object unity

private Rigidbody2D rb;
public Vector2 direction;
public float force;

void Start()
{
	rb = GetComponent<Rigidbody2D>();
    rb.AddForce(direction * force, ForceMode2D.Impulse);
    //rb.AddForce(--pass in Vector--, --can pass in ForceMode--);
}
Posted by: Guest on April-11-2021

Code answers related to "how to add force to an object in unity3d"

C# Answers by Framework

Browse Popular Code Answers by Language