Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: cmonroy on October 16, 2014, 05:02:03 AM

Title: [SOLVED] ScreenToWorldPoint Jittering?
Post by: cmonroy on October 16, 2014, 05:02:03 AM
I have a simple FSM that reads the Mouse X and Y position at a determinated Z position (ten meters away from the camera). Converting that Vector3 to a point inside the game should be easy when using the ScreenToWorldPoint function, which returns a World Vector3, but for some unknown reason the Y component keeps moving randomly even when the mouse is static and basically it starts to fall down from where the mouse is pointing.

Any idea on how to solve this?

Thank you.
Title: Re: ScreenToWorldPoint Jittering?
Post by: Lane on October 16, 2014, 07:25:46 AM
Can you show the other states? Do you have a Joystick plugged in?

You can probably actually just stack all of those three states' actions into one state if you didn't want do do the state loop like that.
Title: Re: ScreenToWorldPoint Jittering?
Post by: cmonroy on October 16, 2014, 10:04:36 AM
Thank you, Lane.

No, I don't use any other input device: just the mouse and the keyboard. I usually do more things in each state, but when things produce unexpected results (as in this case) I tend to oversimplify in order to discard unnecessary clutter.

The original problem is to be able to pick up a World point using the mouse position, but I can't use Mouse Pick because there is not always some geometry to catch the raycast. As such, I use a fixed distance from the main camera to complete the Vector3 (which, by the way changes less than 1% between loops). So, since there isn't any easy way I am aware of to point-and-shoot, I am assuming that positionX and positionY in the screen, plus a fixed-distance point can help me to trace a targeting line, which can be extended to infinity if need be, will intersect my enemies regardless of their distance. When I use the ScreenToWorldPoint function to achieve this end, the input parameters are the correct X and Y coordinates of the screen, then I move a sphere to that precise World Point located 8 meters away from the main camera, but the Y component starts to change randomly and keeps going lower and lower, even if the Y screen coordinate remains at the top of the screen and the Y World component runs towards the negative realm.
Title: Re: ScreenToWorldPoint Jittering?
Post by: Lane on October 16, 2014, 10:26:58 AM
Hmm, I just recreated this and its not drifting. Seems to work correctly. Is something else interfering with the target or tampering with the coordinates?
Title: [SOLVED] ScreenToWorldPoint Jittering?
Post by: cmonroy on October 16, 2014, 10:50:29 AM
Yes... I also have a mecanim character. The jittering is produced by parenting the main camera to the character (which it was done so as to follow around the player from a fixed perspective). Seems like I'm going to have to create a new FSM to take care of the camera...

Thank you Lane.

 :)