Im trying to learn C# with Unity engine
But a basic script like this:
using UnityEngine;
using System.Collections;
public class scriptBall : MonoBehaviour {
// Use this for initialization
void Start () {
Rigidbody.AddForce(0,1000f,0);
}
// Update is called once per frame
void Update () {
}
}
gives this error: Assets/Scripts/scriptBall.cs(8,27): error CS0120: An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)'
i cant find a solution for my problem
AddForceis an instance method ofRigidbody. You need an instance ofRigidbodybefore you can callAddForceon it. Otherwise, what are you adding a force to? - Matt Burland