playMaker

Author Topic: How to Raycast at an angle? [SOLVED]  (Read 5629 times)

markinjapan

  • Full Member
  • ***
  • Posts: 103
How to Raycast at an angle? [SOLVED]
« on: January 15, 2012, 04:41:07 PM »
This is probably really, really easy or really hard. Either way I'm missing it :(

I'm trying to raycast from a gameobject but at a slight angle. I see in the Raycast action there is a direction box so I thought I could simply put a rotation vector in there (like 0,45,0), but it's there wrong type as it's drawing a line in Y with length 45. Not what I wanted.

I guess my question is, how can I convert an rotation Vector3 angle (like 0,45,0) into a direction Vector3?

Is there something I'm missing?

If not, then a Convert Rotation to Direction action would be great :)

Thanks
« Last Edit: January 24, 2012, 04:31:10 PM by alexchouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4143
  • Official Playmaker Support
    • LinkedIn
Re: How to Raycast at an angle?
« Reply #1 on: January 15, 2012, 09:11:17 PM »
The Direction parameter in Raycast is in world space. I've been meaning to add a local choice to this action for a while...

In the meantime, you can use the Transform Direction action to transform a local direction vector to world space. E.g., 45 degrees is (1,0,1) as a direction vector.

Also check Debug in the Raycast action and Gizmos in the Game View to see the ray and make it easier to debug...

See the crappy attached screen  :-\

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4143
  • Official Playmaker Support
    • LinkedIn
Re: How to Raycast at an angle?
« Reply #2 on: January 15, 2012, 09:38:12 PM »