Here, have a look:
Unity - Scripting API: Physics.Raycast[
^]
Physics.Raycast
returns a boolean type. You have assigned that to variable of type
RaycastHit
and thus the error.
It straight away returns true if the ray intersects with a Collider, otherwise false.
Thus,
void Shoot()
{
if (Physics.Raycast(firePoint.position, firePoint.right))
{
}
}
Go through some documentation and article to learn about it, like:
How to Create a Raycast in Unity 3D | Studica Blog[
^]
UPDATE:
A sample for you
void FixedUpdate()
{
int layerMask = 1 << 8;
layerMask = ~layerMask;
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
Debug.Log("Did Hit");
}
else
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white);
Debug.Log("Did not Hit");
}
}
Reference:
Unity - Scripting API: Physics.Raycast[
^]
Suggestion: Please go through the link above and examples there instead of trying to follow some youtube. Until you understand basics and how to use IDE, it would be difficult for you to follow.