Playmaker Forum
Bug Reporting => PlayMaker Bug Reporting => Topic started by: adrian on March 08, 2015, 06:56:12 PM
-
Hi,
I am trying to use raycasting to detect terrain in unity 5 (lastest playmaker) and it never registers hits? is this just for me?
-
Hi,
can you increase the distance value in the raycasting action, it's likely the issue here.
Bye,
Jean
-
Hi Jean,
Thank you for replying, I have tried longer distances and it doesn't seem to work, I am just trying to get the camera to move when its view is obstructed, is there any other way to detect this.
I am struggling a bit to understand the relationship between distance and direction. What sort of values should I try, I was under the impression if I could see the debug line hitting the terrain it should register hit, am I wrong about its operation?
-
Try Raycast instead of Raycast 2 and see if it makes a difference. Could be a bug in the action, although I haven't seen it. Also try on a non-terrain object. (unlikely an issue, but terrains do weird things)
-
Thank you for the advice, I moved onto Raycast 2 after not having any luck with the normal one, really strange bug. Just tried on scene objects and still no hit. Can anyone replicate this in Unity 5 with a simple project. (I have already started new project to check and no luck).
-
Just tested in 5.0 and Raycast hit events do fire property on both normal colliders and terrain colliders.
-
Well that's good, can you see with my setup what I might be doing wrong? should the raycast fire if any part of it is broken or only at the very tip of the raycast? what distance/direction values do you use?
-
All of those variables depend greatly on what you are trying to do.
The direction is where you want the raycast to go from the origin point that you specified. Typically if you want it to go 'forward' you would say xyz 0,0,1 as the Z axis is considered forward, and you would specify to use Self space.
The distance means how far you want the raycast to go before it gives up trying to hit something. This is normally a high number unless you deliberately want it to only be possible to return a hit on very close objects.
The hit event is only fired if the raycast goes in the specified direction and hits something on the layer mask that is within the distance threshold.
The Store Hit Object variable is for storing whatever the raycast happens to hit.
-
Thank you, that is very helpful.
So in my screenshot above I am trying to have it so the camera moves when its view is obstructed by terrain, would you expect it to detect the terrain in the picture with my current settings? if so I might need to go back to the drawing board with my terrain in case that is causing the problem.