Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ToxicFrog on April 09, 2015, 02:24:22 PM

Title: Raycast: How to detect when raycast moves OFF an object?[SOLVED]
Post by: ToxicFrog on April 09, 2015, 02:24:22 PM
Hello friends,

I am using a raycast to detect when it makes contact with a certain object type.

My question:
How can I use playmaker to determine when the raycast is no longer making contact with that object?

In the action, I see there's an event for Hit Event. I'd like something that is the equivalent to 'Hit Ended', if that makes sense.

Any suggestions?

Thanks!
Title: Re: Raycast: How to detect when raycast moves OFF an object?
Post by: mdotstrange on April 10, 2015, 04:17:12 AM
You can use "Get Raycast hit info" to determine the hit object- store that object as a var and use a game object compare set to every frame-
Title: Re: Raycast: How to detect when raycast moves OFF an object?
Post by: ToxicFrog on April 10, 2015, 03:03:31 PM
Thanks for the suggestion, mdot!

I came up with a solution that suits my needs, and thought I'd share it here in case someone else is doing something similar:

Instead of a raycast, I created a really skinny, long box collider that extends 40 units out. Instead of tracking a ray cast hit, I'm using trigger enter/exit. Works perfectly for my purposes here.

Title: Re: Raycast: How to detect when raycast moves OFF an object?
Post by: mdotstrange on April 11, 2015, 12:35:04 AM
Thats actually the same way I do my targeting system  :) Works really well too.
Title: Re: Raycast: How to detect when raycast moves OFF an object?
Post by: BenC on August 09, 2017, 07:24:01 PM
Hey,

I was originally going to use a super long box collider as a child of the main camera. However I thought for an on trigger enter/exit I'd need to attach a rigid body to the box collider? But then that interferes when the camera hits other things in the scene that aren't triggers. Could you explain how you make the box collider register the trigger object without a rigid body?

EDIT: Ohh ok so all I needed to do was add a rigidbody to the object and then turn off gravity and tick 'is kinematic'. Awesome :)