Hi guys, im very new to unity. I know this question has been asked a number of times but i cant seem to get any solutions working…
Currently i have a few cubes. When i click one of these cube game objects i would like to attach the main camera to it.
Each of my game objects has the following function… The function seems to fire ok when i debug it, the problem however is that it can not find the MoveToObject method.
void OnMouseDown() { Camera.main.MoveToObject(); }
Now my main camera has a script attached to it called RtsCamera. The RtsCamera has a
method named MoveToObject.
using UnityEngine; using
System.Collections;public class RtsCamera : MonoBehaviour
{// Use this for initialization void
Start () { } // Update is called
once per frame void Update () { }
public void MoveToObject() {
Debug.Log(“Yay getting somewhere”);
} }
Error
Assets/clicky.cs(17,29): error CS1061: Type UnityEngine.Camera' does not contain a definition for
MoveToObject’ and no extension method MoveToObject' of type
UnityEngine.Camera’ could be found (are you missing a using directive or an assembly reference?)
Thanks in advance,