Need some help.
Monkey Forums/Monkey Programming/Need some help.
| ||
I'm wondering how I would create a method(or class?) to make the mouse's position realtive to a moving object(The player). So the Player's object aims and shoots where the mouse is on the screen. Any help would be appreciated! -DeadFall |
| ||
Relative position is simply (for this example).. xrel = MouseX() - playerx yrel = MouseY() - playery then use ATan2 to get the angle.... ?? Not sure what you are after... |
| ||
[monkeycode]Local firingAngle# = ATan2(MouseY()-playerY, MouseX()-playerX)[/monkeycode] You'll need to take into account any view offset too. Edit: Beaten to it mid-post. |
| ||
Alright thanks matty and samah. Sorry still new at coding. |
| ||
Considering the fact people search forum are based on post subject it could be a good thing to name post with something more efficient like "Mouse relative position" and not the standard one "need help". I said that only to avoid to have the same question in 30 days... |
| ||
To be honest I was tired when I ask the question so I didn't really think ahead. But in the future I will reference the question in the title. |
| ||
Ok DeadFall it's not personnal. But when you are tired dont post in any forum. (well, exept if it's a forum wich subject is tired people.) ;-) |