|
So I have these small panels (0.1 scale, not sure if I should be doing that, or just making the map bigger) I have a larger box collider on the panels, and they are a rigidbody. My code looks like this (Layer 8 is my flashlight, which I don't want the panel to care about, otherwise it should turn left before it hits the object, which it isn't doing) void Update() { LayerMask layerMask = 1 << 8; EDIT: When I use this code, I do hit the wall (though I spin in circles as walls are all around) whenever I add a distance, the plane just walks right up to the wall.
(comments are locked)
|
|
The Layers page on the Unity Documentation shows how to do this. You did create a layer mask but that layer mask is set to hit only layer 8. You'll want to invert it before you use it. I'm getting "Operator '~' cannot be used with an expression of type `UnityEngine.LayerMask'" when I write exactly that---
Sep 30 '11 at 07:44 PM
juanelo
(comments are locked)
|
|
I'm not sure if you have realized that: You set your Ray in Start so it will never change it's position or direction. I can see that you move and rotate your object in the script but your ray will ALWAYS stay at the initial position. It doesn't move along with the object. I guess you want to reinit the ray in Update right before your Raycast. Btw: The layerMask parameter of the Raycast function is just of type int. The LayerMask type has been invented to easily create a layermask value and to display it in the inspector. When you "create" your mask on your own by left-shifting (1 << 8) you don't want to use the LayerMask type at all. Just use an int. If you want to raycast against everything but layer 8 the value you need would be I guess you also don't want to raycast against the ignoreRaycast layer so you should setup your mask like this: I see, thanks, Bunny
Oct 01 '11 at 04:51 PM
juanelo
(comments are locked)
|

right now I am using a second collider, and if wall then I am turning... seems to work, what are the cons of doing it this way?