playMaker

Author Topic: Raycast Gameobject Compare not working correctly.  (Read 1950 times)

fuzzywobs

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Raycast Gameobject Compare not working correctly.
« on: June 23, 2015, 08: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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14342
  • Official Playmaker Support
    • View Profile
Re: Raycast Gameobject Compare not working correctly.
« Reply #1 on: June 23, 2015, 09:02:00 AM »
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

fuzzywobs

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast Gameobject Compare not working correctly.
« Reply #2 on: June 23, 2015, 01: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?!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14342
  • Official Playmaker Support
    • View Profile
Re: Raycast Gameobject Compare not working correctly.
« Reply #3 on: June 24, 2015, 05: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

fuzzywobs

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast Gameobject Compare not working correctly.
« Reply #4 on: June 24, 2015, 06:05:07 AM »
OK, thanks.

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

Many thanks.

terri

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
    • terrivellmann.tumblr.com
Re: Raycast Gameobject Compare not working correctly.
« Reply #5 on: June 24, 2015, 10:25:49 AM »
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.

fuzzywobs

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Raycast Gameobject Compare not working correctly.
« Reply #6 on: July 01, 2015, 05:00:32 AM »
Wait, what happens if you are using a short distanced raycast? How does it work then?