void FlexedUpdate()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Verticle”);
Vector3 movement= new Vector3(moveHorizontal,0.0f,moveVertical);
Rigidbody.Addforce(Vector3);
}
}
void FlexedUpdate()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Verticle”);
Vector3 movement= new Vector3(moveHorizontal,0.0f,moveVertical);
Rigidbody.Addforce(Vector3);
}
}
You need to use references and correct misspelling.
private Rigidbody thisRigidbody;
private void Awake()
{
thisRigidbody = GetComponent<Rigidbody>();
}
//and then anywhere you need it:
thisRigidbody.AddForce(bla bla bla);
For your example it will look like this:
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Verticle");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
thisRigidbody.AddForce(movement);
//or remove movement variable at all and just thisRigidbody.AddForce(new Vector3(moveHorizontal,0.0f,moveVertical));
//or even less coding - thisRigidbody.AddForce(moveHorizontal, 0.0f, moveVertical);
}