playMaker

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

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Raycast broken in unity 5?
« 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast broken in unity 5?
« Reply #1 on: March 09, 2015, 02:47:51 AM »
Hi,

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

 Bye,

 Jean

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Re: Raycast broken in unity 5?
« Reply #2 on: March 09, 2015, 07: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: 2511
  • Mender of the past
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #3 on: March 09, 2015, 08: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)
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Re: Raycast broken in unity 5?
« Reply #4 on: March 09, 2015, 10: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: 2511
  • Mender of the past
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #5 on: March 09, 2015, 10:34:05 AM »
Just tested in 5.0 and Raycast hit events do fire property on both normal colliders and terrain colliders.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Re: Raycast broken in unity 5?
« Reply #6 on: March 09, 2015, 11: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: 2511
  • Mender of the past
    • Cleverous
Re: Raycast broken in unity 5?
« Reply #7 on: March 09, 2015, 11: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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Re: Raycast broken in unity 5?
« Reply #8 on: March 09, 2015, 12:35:00 PM »
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.