|
Hey, Im working on a side scroller and the player rotates left or right depending on the position of the mouse in relation to the center of the screen. Heres the code;
Now what Id like to do is have the players position on screen (the camera has a Lerp smooth follow thing on it) offset were the rotation takes place, kind of like screen.width is local, if that makes sense.
(comments are locked)
|
|
You can get the players position on the screen using Camera.WorldToScreenPoint(). Once you have this you can easily compare it to your mouse position, hope this helps: I guess you want to write
Apr 23 '11 at 01:10 PM
Bunny83
I hadn't spotted that, thanks. I've fixed the code now.
Apr 23 '11 at 01:35 PM
Seregon
Yay! it worked! I love you! I want your babies! etc! etc! one little thing I needed to divide PlayerPosition.x by Camera.main.pixelWidth / 2, where do I post that? do I just answer my own question?
Apr 24 '11 at 03:01 AM
Jason Hamilton
woops I meant to say subtract camer.main from Playerposition....
Apr 24 '11 at 03:02 AM
Jason Hamilton
I'm not sure I understand why you want to do that. I thought the only reason you subtracted half the width was so that you could compare the mouse position to the middle of the screen, and comparing the mouse position to the player position makes that unnecessary? Subtracting half the width from both the player position and mouse position would not affect the result. If I have misunderstood, please explain what your trying to achieve.
Apr 24 '11 at 10:30 PM
Seregon
(comments are locked)
|
