using UnityEngine;
public class PlayerMovement : MonoBehaviour {
// this is a reference to the rigidbody component “rb”
public Rigidbody rb;
public float forwardForce = 100;
// Using FixedUpdate with physics
void FixedUpdate () {
// add forward force to player
rb.AddForce(0, 0, forwardForce);
}
}
You didn’t reference your rigidbody* EDIT I see that you did but wasn’t in the code section*, you most likely didn’t drop the rigidbody into the script and If it still doesn’t work, make sure that your rigidbody is not kinematic, if kinematic is checked it wont move.
public float forwardForce = 100;
Rigidbody rb;
void Start(){
rb = GetComponent<Rigidbody>();
}
// Using FixedUpdate with physics
void FixedUpdate () {
// add forward force to player
rb.AddForce(0, 0, forwardForce);
}