Weird mouse co-ordinates [SOLVED]

The debug line should be drawn to the mouse, the origin is correct. I’m using the example.render script and the screen is set to auto ratio, and set_cameratype_viewproj message is sent in the camera init.

The mouse co-ordinates are stuck inside a smaller box, if I move the character to the right, the mouse co-ords do not move and eventually it will flip the head 180’.

Any ideas?

Are you using action.screen_x, action.screen_y?

Keep in mind that the mouse coordinates will always be in the range of 0,0 to display width,height regardless of the position of the camera. Are you taking the camera position into account when you draw the line?

2 Likes

Thanks @Pkeod for the help, yes, the code is taken straight from @britzl rotate and move examples on Git. @britzl my mind wasn’t thinking along those lines at all, this game making business is hard, I’m guessing is not a simple as adding the camera position to the mouse co-ords.

thanks for your help.

1 Like

If you subtract the camera world position from the player world position you get the screen position of the player. You can then use this as one end of the line and the mouse coordinates as the other.

2 Likes

thanks for the help gents, once I’d taken the world cam co-ords into account I was able to get the right angle for the head, so at least it rotates and looks at the mouse correctly now, which is all that matters at this time.

2 Likes