Question by
HashimJaved · Aug 19, 2017 at 06:50 PM ·
exception
NullReferenceException: Object reference not set to an instance of an object PlayerController.FixedUpdate () (at Assets/Scripts/PlayerController.cs:20)
Here is my script:
using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour { public float speed; private Rigidbody rb;
void start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
}
Comment
Your answer
Follow this Question
Related Questions
Invalid PBX project - iOS Build Help! 2 Answers
Variable has been assigned but has UnassignedReferenceExcecption 1 Answer
Problem with Lists and Remove 0 Answers
Facing Null Reference Exception 0 Answers
Cannot set parent for instantiated GameObject. (Exception: Can't destroy Transform component of...) 0 Answers