Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: holyfingers on February 05, 2014, 04:42:13 PM

Title: Issue with Screen to World Point...
Post by: holyfingers on February 05, 2014, 04:42:13 PM
I'm having an odd issue at the moment with Screen to World Point...

I'm using a sphere as a cursor, it's parented under the Main Camera in scene, if I attach the following script it follows the mouse perfectly no matter what the rotation of the camera is:

Code: [Select]
function Update () {

var screenPoint : Vector3 = Input.mousePosition;
screenPoint.z = distanceFromCamera; //distance of the plane from the camera
transform.position = Camera.main.ScreenToWorldPoint(screenPoint);

}

If I set up an FSM using Get Mouse x/y, passing them to Screen To World Point and then setting the x/y position of the sphere, it works fine if the camera is 0,0,0 but drifts away from the cursor if I rotate it at all?

I've got the scene working by using a combination of the above script and various FSMs but I'm just curious what the discrepancy might be? Anybody else using Screen To World Point in a similar manner and getting better results? Am I missing something obvious?

Thanks for your time,

Nick