I think I found a bug. (or I didn't follow the leture correctly!)

In the OnUpdate() function in CameraRaycaster we only call the OnLayerChange event if we hit a layer.

If we don’t hit a layer it falls through to set the layerHit to being the RaycastEndStop but doesn’t call OnLayerChange so the cursor affordance isn’t being being told to change the cursor to unknown.

In my code I’ve fixed this by adding OnLayerChange(Layer.RaycastEndStop); at the very end of the update function in the CameraRaycaster.cs

3 Likes

Need to check Ben’s changes at this point after dinner as i think this was the culprit

1 Like

Thats it! thanks!

thats the fix., although I think we probably want to still set layerHit on our class. That’s a class field that we have exposed a public property for ( currentLayerHit ) and we probably still want to set that accordingly so other classes can get the right current layer status at any time.

// Otherwise return background hit
    raycastHit.distance = distanceToBackground;
    layerHit = Layer.RaycastEndStop;
    onLayerChange(Layer.RaycastEndStop)'
1 Like

I seem to remember having to remove this as once it set to unknown it stay there so WIP still.
Unless i just got a random glitch.

When I found and fixed this I kept the line that sets the layerHit and there didn’t seem to be an issue.

2 Likes

I noticed this as well and made the following change:
if (layerHit != Layer.RaycastEndStop) { layerHit = Layer.RaycastEndStop; onLayerChange(layerHit); }

Omg thankyou so much,I rewatched this video 6x and didn’t understand what my problem was! Thankyou again,I can begin putting my hair back into my head,as a sidenote C# is really flustering,i’m a week into it. So much to learn…

As a sidenote,this is my only error at this point in time,anyone know why?? I didn’t do wsad and gamepad btw.

Should not be capturing when there is a hotcontrol
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Privacy & Terms