- Home /
Question by
FPSworrior · Oct 28, 2013 at 04:10 PM ·
errorerror message
Error with script.
I don't know what the error mean. It says Camera does not contain a definition for 'main'. Can someone help me figure this out?
using UnityEngine;
using System.Collections;
public class ReticleMovement : MonoBehaviour
{
void Update ()
{
Ray ray = Camera.Cam.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hits;
hits = Physics.RaycastAll(ray);
foreach(RaycastHit h in hits)
{
if(h.collider.name == "ground")
transform.position = new Vector3(h.point.x, 5f, h.point.z);
}
}
}
Comment
Best Answer
Answer by Deathdefy · Oct 28, 2013 at 04:12 PM
Change
Ray ray = Camera.Cam.ScreenPointToRay(Input.mousePosition);
to
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
That should fix your issue