Confusing slide

Just one heads up that confused me, the challenge slide said to attach cursor to the camera, so I attached it to the main camera object, not the camera arm, like you do in the rest of the video and then findByType. I then had the added confusion of calling the raycaster script from a different gameobject, so had to create a reference to the camera arm and get the raycaster script that way.

You should alter the slide to say to attach it to the camera arm I think, it makes things a lot easier if its on the camera arm and you’re in the same gameObject? Was I just stupid?

public class Cursor : MonoBehaviour
{
    // get a reference to the camera arm with the raycaster script in it.
    public GameObject myCamArm;

    // hold that script for us to work with it
    private CameraRaycaster myCaster;


    // Use this for initialization
    void Start ()
    {
        myCaster = myCamArm.GetComponent<CameraRaycaster>();
    }

    // Update is called once per frame
    void Update ()
    {
        // print layerHit each frame
        Debug.Log(myCaster.layerHit);
    }
}

Privacy & Terms