Hi everyone of the internets, I’m here to ask a questions that MIGHT have a VERY simple answer, but I just can’t figure it out. So basically I’m creating a FPS with my friends, but I have ran into a problem with a script. Here’s the script:
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
public class PlayerNetworkMover : Photon.MonoBehaviour
{
public delegate void Respawn(float time);
public event Respawn RespawnMe;
public delegate void SendMessage(string MessageOverlay);
public event SendMessage SendNetworkMessage;
public float health = 100f;
Vector3 position;
Quaternion rotation;
float smoothing = 10f;
bool aim = false;
bool sprint = false;
bool initialLoad = true;
Animator anim;
void Start()
{
anim = GetComponentInChildren<Animator> ();
if(photonView.isMine)
{
transform.Find ("MainCamera/Camera/Ak-47").gameObject.layer = 9;
transform.Find ("MainCamera/Camera/Ak-47/Ak47Body").gameObject.layer = 9;
transform.Find ("MainCamera/Camera/Ak-47/Ak47Mag").gameObject.layer = 9;
transform.Find ("MainCamera/Camera/Ak-47/Cube_001").gameObject.layer = 9;
GetComponent<RigidbodyFirstPersonController>().enabled = true;
GetComponent<Rigidbody> ().useGravity = true;
GetComponent<Crouching>().enabled = true;
GetComponentInChildren<PlayerShooting> ().enabled = true;
GetComponentInChildren<AudioListener> ().enabled = true;
foreach(Camera cam in GetComponentsInChildren<Camera>())
cam.enabled = true;
}
else
{
StartCoroutine("UpdateData");
}
}
It’s the start of a script copied from the Unity Merry Fragmas Live Tutorial, edited to fit my needs. So the problem is in this line:
GetComponent<RigidbodyFirstPersonController>().enabled = true;
It’s properly located in the inspector as seen:
but when I run the game, Unity gives me a Object reference not set to an instance of an object error.
And I CAN’T figure out why. So if anyone with the powers of Unity far beyond me can help, it would be much appreciated.
Thanks For Reading!