Cannot implicitly convert `UnityEngine.RaycastHit` to `bool`
I'm having the error with this code { public RaycastHit Hit; public GameObject Player;
void Start ()
{
if (Hit)
{
}
}
}
Comment
Answer by Jawchewa · May 07, 2017 at 11:31 PM
I'm not really sure what you're trying to do here, but I would recommend looking at the documentation for Unity raycasting here:
https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
It tells you how to perform raycasts, and see if anything has been hit. As for the error that your getting, the reason that it's throwing an exception is because you can only perform if checks on boolean statements, so you can't call if with a RaycastHit argument.