playMaker

Author Topic: Raycast not aligning up properly  (Read 1629 times)

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • Online Playmaker Courses
Raycast not aligning up properly
« on: February 02, 2014, 01:03:44 AM »
Hi guys,

I am trying to use the raycast to align between my main camera and the 3d object that I am using as a cursor.

But for some reason the ray doesnt pass through the cursor. It seems go in general direction but I am just confused why it is not passing thought the point.

What I want to do in the end is detect a point on the yellow plane and have an object move to that location.

Note If i use world over self the raycast is even worse.
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast not aligning up properly
« Reply #1 on: February 03, 2014, 05:25:25 AM »
Hi,

 yes, you are likely not computing the direction vector properly.

The mouse position is expressed in screen coordinates, not in 3d coordinates.
 
So, for this, I would use the following scene as a starting point. It's a small sample showing how to have an object looking at the mouse, use this as your way to get the real direction in world of the mouse direction compared to another 3d object.

bye,

 Jean