Question by
eze09 · Jan 03, 2016 at 09:21 AM ·
object reference
Hello everyone, im really new to unity and i was trying to get a sphere to jump then i got an error "An object reference is required to access non-static member". I want to learn how to fix this
Here is my code...
using UnityEngine; using System.Collections;
public class jump : MonoBehaviour {
public float sphereJump = 10;
Rigidbody spherebody;
void Awake () {
spherebody = GetComponent<Rigidbody>();
}
void FixedUpdate () {
if (Input.GetButtonDown ("Jump"))
Rigidbody.AddForce (0 ,sphereJump ,0);
}
}
i really need help thanks
Comment
welcome.
in future, please format ALL of your code.
try changing line 12 (as posted) to the following:
spherebody.AddForce(0, sphereJump, 0);
Your answer
Follow this Question
Related Questions
error CS0120: An object reference is required to access non-static member 1 Answer
Object Reference Error 2 Answers
Object reference not set to instance of an object? 1 Answer
Unable to create a reference to an instantiated object and alter it? 1 Answer
Object reference is required to access non-static member? 1 Answer