I have a very basic horse race game (cube race actually). My ‘horse’ has a script
using UnityEngine;
using System.Collections;
public class Horse : MonoBehaviour
{
public void Run()
{
transform.position += new Vector3(Random.Range(0,0.1f), 0, 0);
}
}
and I have an empty GameObject with a script
using UnityEngine;
using System.Collections;
public class Race : MonoBehaviour
{
public GameObject[] horses;
void Start ()
{
horses = GameObject.FindGameObjectsWithTag("horse");
}
void Update ()
{
for(int i=0;i<horses.Length;i++)
{
horses[i].Run();
}
}
}
but Unity does not want to run my Run() method. Something about no extensino method or missing assembly reference etc. Is there some magic word I should be using? The code is very incomplete at this stage, but I need to get this working first.