Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Need help with this

Author
Message
Ace1009
15
Years of Service
User Offline
Joined: 5th Feb 2009
Location:
Posted: 6th Feb 2009 01:47
OK hope someone can help me! I need to track the mouse cursor and to have a spaceship to angle toward the mouse cursor to always face the mouse corsor. If you can help please do. Thank you.

Ace
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Feb 2009 05:14
what are you using? if you are using dbc theres some functions i saw a while back to rotate sprite and if you using dbp i think i herd that it has a rotate sprite command and darkgdk i have no idea lol. and you can use MouseX() and MouseY() (for dbc and maybe dbp) to get the mouse position and then rotate it toward it.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 6th Feb 2009 12:10
Do you want a smooth rotation towards the mouse cursor? Or just a always 'point at' mouse cursor?

Well, first thing you need to do is find the angle from point A(object) to point B(mouse) Simple use of SIN() COS() will accomplish this. Then it's a matter of setting the object's angle. Either setting it, or adding a curvevalue().

Ace1009
15
Years of Service
User Offline
Joined: 5th Feb 2009
Location:
Posted: 6th Feb 2009 15:50
Thanks for the help all! I thought about it and came up with pretty much the same thing as josh. Thank you for help!

Ace
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 7th Feb 2009 15:29
Quote: "Well, first thing you need to do is find the angle from point A(object) to point B(mouse) Simple use of SIN() COS() will accomplish this."


I think the command ATANFULL is generally accepted as the best way to do this.

Login to post a reply

Server time is: 2024-04-23 08:41:00
Your offset time is: 2024-04-23 08:41:00