Question by
danny1111 · Dec 17, 2015 at 07:58 PM ·
error messageobject reference
NullReferenceException: Object reference not set to an instance of an object
I don't understand what's wrong.
//SpeedController.cs
using UnityEngine;
using System.Collections;
public class SpeedController : MonoBehaviour {
public float speed;
void Start(){
speed=0.1f;
}
void Update(){
Debug.Log (speed);
}
}
//ClickController.cs
using UnityEngine;
using System.Collections;
public class ClickController : MonoBehaviour {
private GameObject[] cubes;
public SpeedController _SpeedController;
private float thisSpeed;
void Start(){
//thisSpeed = 0.1F;
cubes=GameObject.FindGameObjectsWithTag("SquaresTag");
InvokeRepeating ("Expand",1,0.03F);
thisSpeed = 0.1F;
}
void Expand(){
if(transform.position.z>0){
transform.position -= new Vector3 (0,0,thisSpeed);
}
}
void OnMouseDown(){
foreach(GameObject hello in cubes){
hello.transform.position+= new Vector3(0,0,10);
_SpeedController.speed+=0.1f;
thisSpeed=_SpeedController.speed;
}
}
}
Can you help please? Thanks
Comment
Your answer
Follow this Question
Related Questions
When enemy dies the script loses object reference. 1 Answer
[Begginer] [Solved] How to solve a Null Reference Exception 1 Answer
A list of a struct doesn´t saw a word in the console. Object reference, but i dont have anyone 1 Answer
Array of dictionaries: "Object reference not set to an instance of an object" 0 Answers