This is what I see when I start up the game: https://i.stack.imgur.com/IpXkx.png The last error happens when I press "space".
Ok, so I even put the "ResourcesScript" onto the "Cube" manually from the editor and it still can't find it with "GetComponenet ();" :S The Actor class was initially used to create the component (and ITS reference to it exists and is not a null):
void Awake () {
resource = gameObject.AddComponent <ResourcesScript> ();
}
This is the entire ResourcesScript:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ResourcesScript : MonoBehaviour {
public GameObject attatchedGameObject;
public Rigidbody attatchedRigidbody;
public BehaviourStateResource behaviourResource;
public BehaviourStateManager behaviourManager;
public MovementStats moveStats;
public MovementStatsManager moveManager;
public State currentMovementState;
public HealthStats healthStats;
public HealthStats armorStats;
public HealthStats shieldStats;
//public HealthManager healthManager;
void Start () {
attatchedGameObject = gameObject;
attatchedRigidbody = gameObject.GetComponent <Rigidbody> ();
behaviourResource = new BehaviourStateResource ();
behaviourManager = gameObject.AddComponent <BehaviourStateManager> ();
moveStats = new MovementStats (new Stat (10.0f), new Stat (10.0f), 10.0f, new Stat (10.0f), new Stat (10.0f), 10.0f);
moveManager = new MovementStatsManager (this);
currentMovementState = gameObject.AddComponent <DefaultState> ();
healthStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
armorStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
shieldStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
//healthManager = gameObject.AddComponent <HealthManager> ();
}
}
And finally, this is an example of a class that uses the GetComponent to get the object... but fails to find one:
public class BehaviourStateManager : MonoBehaviour {
public ResourcesScript resource;
void Start () {
resource = gameObject.GetComponent <ResourcesScript> ();
Utilities.Validate <ResourcesScript> (resource, this);
}
}
I've been at this for a long time and I can't seem to find the problem.