playMaker

Author Topic: Raycast broken in unity 5?  (Read 4710 times)

adrian

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Raycast broken in unity 5?
« on: March 08, 2015, 03: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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Raycast broken in unity 5?
« Reply #1 on: March 08, 2015, 11:47:51 PM »
Hi,

 can you increase the distance value in the raycasting action, it's likely the issue here.

 Bye,

 Jean

adrian

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast broken in unity 5?
« Reply #2 on: March 09, 2015, 04:52:30 AM »
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?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #3 on: March 09, 2015, 05:31:55 AM »
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)

adrian

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast broken in unity 5?
« Reply #4 on: March 09, 2015, 07:25:52 AM »
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).

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #5 on: March 09, 2015, 07:34:05 AM »
Just tested in 5.0 and Raycast hit events do fire property on both normal colliders and terrain colliders.

adrian

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast broken in unity 5?
« Reply #6 on: March 09, 2015, 08:06:53 AM »
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?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #7 on: March 09, 2015, 08:30:01 AM »
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.

adrian

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast broken in unity 5?
« Reply #8 on: March 09, 2015, 09:35:00 AM »
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.