My script worked fine for like 10 minutes and then stopped working. I didn’t change it at all and i get the same error every time. Could some one please explain why my script doesn’t work?
function GetActions(){
var players = GameObject.FindGameObjectsWithTag ("Player"); // Fineds all the players in the scene
for (var p : GameObject in players){ // sets p as a game object for every player in the scene
var PlayerComponent : Component = p.GetComponent("Player"); // Gets the component of every player in the scene
var PlayerTransform : Transform = p.GetComponent(Transform);
Debug.Log("I found " + players.Length + " players");
if (PlayerComponent.turnEnded){ // If the current player made a move
if (PlayerComponent.NextTurnMove){ // if the player moved for his turn
PlayerTransform.position = PlayerComponent.nextMovingPosition; // get the position he wants to move to
PlayerComponent.turnEnded = false; // allows the player to move for the next turn
}
}
}
NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
Turn.GetActions () (at Assets/Scripts/Turn.js:69)
Turn.Update () (at Assets/Scripts/Turn.js:29)