so I have two scripts in seperate objects and i am trying to get them to communicate
in object tickobject
//this program is meant to take delagates and call those delagates every 1 second interval
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
//public delegate void playertick;
public class tickscript : MonoBehaviour {
public double timesincetick;
public delegate void playertickclas();
public List itemlistz = new List(1);
void Start () {
itemlistz = new List<playertickclas>();
}
public void settick(playertickclas a){
Debug.Log ("tick set");
this.itemlistz.Add(a);
}
// Update is called once per frame
void Update () {
Debug.Log(itemlistz.Count);
foreach(playertickclas tickfunction in itemlistz){
tickfunction();
}
}
}
and in an object called test tick reciver
using UnityEngine;
using System.Collections;
public class tickreciver : MonoBehaviour {
void Start () {
GameObject.Find ("tickobject").GetComponent<tickscript>().settick(tock);
Debug.Log ("ran");
}
public void tock(){
Debug.Log ("tock");
}
}
I expected it to output:"
tickset
ran
tock
tock
tock
“…
but it outputed:”
tickset
ran
0
0
0
0"
…
what did i do wrong?