Need some help.

Monkey Forums/Monkey Programming/Need some help.

DeadFall(Posted 2012) [#1]
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


matty(Posted 2012) [#2]
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...


Samah(Posted 2012) [#3]
[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.


DeadFall(Posted 2012) [#4]
Alright thanks matty and samah. Sorry still new at coding.


golomp(Posted 2012) [#5]
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...


DeadFall(Posted 2012) [#6]
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.


golomp(Posted 2012) [#7]
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.)
;-)