I started experimenting with Unity only today. I was going through a video project tutorial “Roll-a-Ball” and I got this error in the following script. The code is exactly as shown in the tutorial. I cannot figure out what’s wrong with this. Help, anybody, please?
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);
}
}
To use a non static method you need an object of that type. Right now you are using a class type instead of an object of that type. For instance you can do the following int x=0; string text=x.ToString(); but cannot do the following string text=int.ToString();
– maccabbeYes. I tried doing that. I did this. It didn't work. Rigidbody rigidbody; rigidbody.AddForce(x,y,z);
– sfllhkhan95