playMaker

Author Topic: 2D Ray Cast broken?  (Read 4483 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
2D Ray Cast broken?
« on: March 09, 2014, 05:57:09 PM »
Is there a trick to this?? I can add a cube and use the normal 3D raycast and the debug line works as expected but when I try to do it with Ray Cast 2D - I can't get any debug line to show. Is it broken?

Thanks.

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: 2D Ray Cast broken?
« Reply #1 on: March 10, 2014, 10:42:33 AM »
Or maybe it needs to be a certain collision type or object to work in 2D? I'm lost...  :o

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2D Ray Cast broken?
« Reply #2 on: March 14, 2014, 08:00:55 AM »
Hi,

 First, everything as to be 2d, you can't mix 3d physics and 2d physics, can you double check this?

bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: 2D Ray Cast broken?
« Reply #3 on: March 22, 2014, 11:41:28 AM »
Yeah, I've double checked and still can't get it to work.

Lets say I have a sprite with rigidbody and box Collider 2d with Raycast2D attached. On hitEvent, I store the Object hit and moved to a Game Object Compare Tag. This looks for the Tag 'Player'. If it's not hit a Player tag, it waits for 1 second and tries again. If it does hit 'Player' Tag it should do something different but it never does.

Does Raycast2D not work with Game Object Compare Tag? Or Sprite?

If I add a cube child to the Sprites and use Raycast3D into Game Object Compare - it will work.



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2D Ray Cast broken?
« Reply #4 on: March 25, 2014, 09:18:27 AM »
Hi,
 
 You are likely not firing the ray as you imagine you do,

"Game object compare tag" works in all situations, so it's likely that the Raycast2D is not finding anything to begin with.

I doubled checked and everything is working as expected.

can you debug the ray ( check the "debug" option in the action") and make sure you see a yellow line in the scene view that is exactly what you expect the raycast to be, if you don't see that yellow line, then it's your setup that is wrong.

bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: 2D Ray Cast broken?
« Reply #5 on: March 27, 2014, 08:35:37 AM »
Yeah, I can see the yellow line. I'll make up a quick scene and attach it - I know it's just me being dumb haha.

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: 2D Ray Cast broken?
« Reply #6 on: March 15, 2015, 05:45:23 PM »
I am having the same problem, same set up, for some reason my Raycast hit my NPC Game Object, at all times, and never hits the player even if it's right infront of it.

The NPC is Untagged as well.

The Has the tag Player

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2D Ray Cast broken?
« Reply #7 on: March 18, 2015, 02:18:12 AM »
Hi,

 when things like that do not work as expected, make a new scene with just one object and try to raycast on it, then work from there. It's likely a mix of issues and setup that leads to a malfunctionning behavior.

 Bye,

 Jean