Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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--);
}
 
PREVIOUS NEXT
Tagged: #add #force #object #unity
ADD COMMENT
Topic
Name
6+4 =