Get mouse position relative to game world? |
riksweeney
|
2D or 3D? Please provide some more detail about what you're trying to do.
|
|||||||||||
|
Laggy44
|
It's 2D. I need to figure out the angle that a bullet sprite should be set to in order to move in the proper direction. The player aims with the mouse, and I need to find the distance between the player's sprite and the cursor in order to get the proper angle.
Just a few minutes ago, I did realize that since the player's sprite is always in the very center of the screen, I could simply check the distance from the mouse to the center of the screen. Here's a screenshot using the above method. It doesn't work perfectly just yet, but I think I know how to fix it. |
|||||||||||
|
^DJ_Link^
|
I have some classes in my engine to help with that.
The basic formula you can use is something like.
mouse_v_pos is a Vector2, pretty much a class with X, Y. Matrix is the class that holds transformations. To generate your camera Matrix
Matrix functions needed
I hope this helps |
|||||||||||||||||
|