Hi, I am trying to control the four corners of the mouse with raycasting. At the distance I specify, if there is a tag, write “found! :)” on the console.
if (Physics.Raycast (hit.transform.position, Vector3.left, out hit, 1.0f)
|| Physics.Raycast (hit.transform.position, Vector3.right, out hit, 1.0f)
|| Physics.Raycast (hit.transform.position, Vector3.forward, out hit, 1.0f)
|| Physics.Raycast (hit.transform.position, Vector3.back, out hit, 1.0f)) {
if (hit.collider.transform.tag == "redbox") {
print ("found! :)");
}
}
But it does not work and it always gives the same error.
NullReferenceException: Object reference not set to an instance of an object
I want to check around the mouse.I am trying to do this using raycast.I do not know if there is any other way of doing this, It did not work in the alternative ways I thought.Below is the mouse that appears as a result of right clicking.
Is it possible to find out which tag is in the ending points of the gray colored lines?