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