here is what I’m stuck on: Add the script to a gameobject and create another gameobject to set as the target, make sure they are both at 10 z. Also set the raycaster’s terrain variable to the gameobject containing the polygon generator.
Do you see those variables declared near the top with “public (inserttypehere) (insertnamehere)”? Those you can “edit” from the Inspector window when you click on the GameObject with the script on it. Just click on the GameObject, scroll down until you see the script, and if it isn’t open, open that component (the script).
Now, you’ll see the field for the target variable as empty. All you have to do now is drag the other GameObject from the hierarchy into that slot. Done!
(Yes, don’t click, wait, then drag the other object. The inspector will change then. Do a quick drag.)
It doesn’t work because of my code… I think.
Here is my code.
I think it’s the layerMask
Here are my errors.
Assets/Scripts/RaycastExample.cs(24,110): error CS0103: The name layerMask' does not exist in the current context Assets/Scripts/RaycastExample.cs(23,29): error CS1502: The best overloaded method match for UnityEngine.Physics.Raycast(UnityEngine.Vector3, UnityEngine.Vector3, out UnityEngine.RaycastHit, float, int)’ has some invalid arguments
Assets/Scripts/RaycastExample.cs(23,29): error CS1503: Argument #5' cannot convert object’ expression to type `int’