I am doing the tutorial for the Roll-A-Ball game. I am on the “Move the Player” step, and the code that the tutorial has you typing out doesn’t seem to work.
Here is a copy of the code that I have typed out myself:
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);
}
}
And here is a copy of the error that it is throwing: Assets/Scripts/PlayerController.cs(13,27): error CS0120: An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)’
It’s having an issue with the Rigidbody.AddForce, and I can’t seem to get it to resolve. I have done some research, but as I am a new to doing any of this, it’s all a bit above my head at the moment. L’il help?
Thanks much.