Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-31-2009, 05:19 PM   #1
Registered User
Join Date: Aug 2009
Posts: 28
Default [AS3] Rotate Turret based on Mouse Position

Ok so I'm having a hard time getting this to work. I am trying to get this turret to rotate according to where the mouse is. Now technically it works but I want to have the turret point directly at the mouse. Attached is the folder containing the FLA and Actionscript. Anyone has any suggestions let me know. Also if anyone has any experience with the Pulse Particle extension, I could really use some help with making the water lines turn into a splash effect.
Attached Files
File Type: zip water cannon_v1.3.zip (158.8 KB, 326 views)
discretion is offline   Reply With Quote
Old 08-31-2009, 05:56 PM   #2
Greg SS
Uber sleepy
Join Date: Nov 2007
Location: Bandung
Posts: 886
Send a message via Yahoo to Greg SS

turret.rotation = Math.atan2( mouseY - turret.y, mouseX - turret.x ) * 180 / Math.PI;
My help efforts are postcardware.
PM me for my local address to send your postcard if you're kind enough to indulge my weird hobby.
Greg SS is offline   Reply With Quote
Old 08-31-2009, 06:43 PM   #3
Registered User
Join Date: Aug 2009
Posts: 28

let me try that again cause I've tried that once and had problems.

Yeah i just tried it and it points in the wrong direction completely.

Went back and looked and its because of the layout of the barrel in its movieclip. just switched it's x location to 0 and it worked.

Last edited by discretion; 08-31-2009 at 06:52 PM.
discretion is offline   Reply With Quote
Old 06-04-2014, 12:59 AM   #4
Registered User
Join Date: Jun 2014
Posts: 1
Default Thanks this answer helped me .

Although I was dealing with html5 and javascript this solution does help me. But I have to negative the angle once it is obtained to make this work correctly.

Anyways thanks for your answer.
ysrikanth2011 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:15 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.