Awesome, works, thank you! ----- Original Message ----- From: "Jobe Makar" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <[email protected]> Sent: Monday, February 06, 2006 12:00 PM Subject: Re: [Flashcoders] Bullet Angle
Hi, Reverse the difference calculation in the atan2 method. Those parameters determine the slope from the perspective of one of the two points. So change it to this and it should work: var theRadians:Number = Math.atan2(( goodGuy._y-_y), (goodGuy._x-_x)); Jobe Makar http://www.electrotank.com http://www.electro-server.com phone: 919-609-0408 mobile: 919-610-5754 fax: 919-341-8104 ----- Original Message ----- From: "JesterXL" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, February 06, 2006 11:56 AM Subject: [Flashcoders] Bullet Angle > I've got some bullet code that is dependent upon the rotation. However, > my > results are backwards; meaning, I have to invert my results to get the > bullet to move at the right angle. Granted, it works, but I feel > uncomfortable since I don't understand why it's backwards. Anyone explain > why, or give me a better algo? > > // my ship > var theRadians:Number = Math.atan2((_y - goodGuy._y), (_x - goodGuy._x)); > var theDegrees:Number = theRadians * 180 / Math.PI; > _rotation = theDegrees; > > // the bullet code > var deltaX:Number = targetX - _x; > var deltaY:Number = targetY - _y; > var angle:Number = p_shipFiring._rotation; > angle = angle * Math.PI / 180; > theX = speed * Math.cos(angle); > theY = speed * Math.sin(angle); > // only works if I invert...??? > theX *= -1; > theY *= -1; > > Thanks if you can help! > > --JesterXL > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

