Im working on a multiplayer fps and I keep getting this code,
NullReferenceException: Object reference not set to an instance of an object
PlayerController.Update () (at Assets/PlayerController.cs:27)
any ideas why. im a beginner at this so sorry if this is a stupid question
Heres my code
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour {
[SerializeField]
private float speed = 5f;
private PlayerMotor motor;
void start ()
{
motor = GetComponent();
}
void Update ()
{
float _xMov = Input.GetAxisRaw(“Horizontal”);
float _zMov = Input.GetAxisRaw(“Vertical”);
Vector3 _movHorizontal = transform.right * _xMov;
Vector3 _movVertical = transform.forward * _zMov;
Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed;
motor.Move(_velocity);
}
}