playMaker

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

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • View Profile
    • Online Playmaker Courses
Raycast not aligning up properly
« on: February 01, 2014, 11:03:44 PM »
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: 14564
  • Official Playmaker Support
    • View Profile
Re: Raycast not aligning up properly
« Reply #1 on: February 03, 2014, 03: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