Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: fuzzywobs on June 23, 2015, 11:43:36 AM

Title: Raycast Gameobject Compare not working correctly.
Post by: fuzzywobs on June 23, 2015, 11:43:36 AM
I'm struggling with something that was not an issue before (pre Unity 5.1?). Raycasting seems to be completely unreliable for some reason with the Equal Event and Not Equal Event not working correctly.
I have a raycast set up on my FPS controller with a gameobject global variable. I want to set it up so that if the raycast strikes a certain object, that object will change colour. If the raycast is not hitting the object, it returns to the original colour.
The thing that is most unreliable is the "Not Equal Event". There are some clear cases where the raycast is no longer hitting the object, yet the object stays highlighted and stuck in the FSM. When I've tested it, going horizontally through an object seems to change it back and forth correctly. When looking up and down the FSM seems to be stuck in the state that has "Equal Event" when it clearly is not. Sometimes shaking the mouse seems to resolve it.

Anyone any ideas?
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: jeanfabre on June 23, 2015, 12:02:00 PM
Hi,

 Odd. So you confirm that the same scene worked before without any changes at all? I'll double check on my end.

 If you can extract a minimal repro case, that would be great.

 Bye,

 Jean
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: fuzzywobs on June 23, 2015, 04:05:50 PM
Not the exact same scene, but the same scripts were applied.

I did a bit of debugging and I discovered that the ray-cast doesn't register as "Not Equal To" until it hits any object other than the object with the script. 

So in my original scene which was in a small room, when moving off the selectable item, it would always hit off something (wall etc) since it was full of geometry so it worked fine. When testing in a plain scene that just had a plane and a cube in the air, the problem is apparent. if you look at the cube in the air, then look away from the cube without hitting any other geomery it doesn't register as being "off" the object.

I guess I can solve this by making sure theres always something to hit (in the out door scenes I guess I can just put a huge invisible box collider around the scene).

Any thoughts of a proper workaround? Am I doing something wrong or not using it correctly?!
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: jeanfabre on June 24, 2015, 08:21:49 AM
Hi,

 that works for me, I remember I did something like that too, because the other options means a lot of setup in each fsm to catch this, so go for this.

Bye,

 Jean
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: fuzzywobs on June 24, 2015, 09:05:07 AM
OK, thanks.

In that case you can mark this issue as <Solved>.

Many thanks.
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: terri on June 24, 2015, 01:25:49 PM
A Raycast that returned to the Gameobject to null when not hitting anything would be awesome though.

I've done this invisible collider at the end thing, or sometimes just checking the Did Hit bool will work.
Title: Re: Raycast Gameobject Compare not working correctly.
Post by: fuzzywobs on July 01, 2015, 08:00:32 AM
Wait, what happens if you are using a short distanced raycast? How does it work then?