adding force unity code example
Example 1: unity how to add force
public Rigidbody rb;
if(Input.GetKey(KeyCode.W))
{
rb.AddForce(100, 0, 0);
}
Example 2: unity rigidbody addforce
rb = GetComponent<Rigidbody>();
rb.AddForce(new Vector3(1.5f,1.5f,1.5f));
Example 3: rb.addforce c#
rb.AddForce(0, 0, 5 * Time.deltaTime);
// Time.deltaTime is optional ( Make sure that "T" is caps)
Example 4: rb.addforce 3d c#
rb.AddForce(0, 0, 5 * time.deltaTime);
// time.deltaTime is optional