unity how to add force
public Rigidbody rb;
if(Input.GetKey(KeyCode.W))
{
rb.AddForce(100, 0, 0);
}
unity how to add force
public Rigidbody rb;
if(Input.GetKey(KeyCode.W))
{
rb.AddForce(100, 0, 0);
}
unity rigidbody addforce
rb = GetComponent<Rigidbody>();
rb.AddForce(new Vector3(1.5f,1.5f,1.5f));
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--);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us