I have just started to use Unity, and I went on the first game tutorial (Roll-A-Ball) to learn some of the basics. However, once I got on to making the script to move the character, an error came up on my code that didn’t come up on the tutorial.
Here is the code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
*Rigidbody.AddForce (movement);*
}
}
However, on line 13 (the line with asterisks) it says “An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)'”.
As I have just started Unity, I have no idea how to do this, nor can I find anything on the website itself about this.
Can you please help me fix this.