The Daily Click ::. Forums ::. Klik Coding Help ::. Direction-Angle problem
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
9th January, 2013 at 09/01/2013 13:05:52 -

I created a turret witch should always be turning to the direction of an object that always looks in the mouse pointer object. The problem is that when i move the cursor over the "zero point" it turns 360° in reverse direction when it should only go over the "zero point". Hard to explain, easy to see:

http://speedy.sh/YVeWG/direction-angle-problem.mfa

 
[Signature][/Signature]

Akai_R



Registered
  16/04/2008
Points
  436
9th January, 2013 at 09/01/2013 15:57:16 -

its because when it hits 0, your "compare two values" goes from being greater to lesser (or vice versa), and since theres two different events that handle these, it starts turning the other way... Im sure youre well aware of it, but Im to tired to think right now, sorry
Couldnt you use the advance direction object? Im sure theres an event there for rotating against a target.

 
______
http://akai-r.com/

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th January, 2013 at 09/01/2013 16:57:58 -

Scrap the last two lines and add this:

+ Always
-> Set Angle of Flak Cannon to: Angle( "flak cannon visPart" )+Max(Min((((ATan2(Y( "flak cannon visPart" )-YMouse, XMouse-X( "flak cannon visPart" ))-Angle( "flak cannon visPart" )+540) mod 360)-180), 1), -1*1)


This formula and others can be found here: http://www.sketchy.co.nf

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
9th January, 2013 at 09/01/2013 19:09:07 -


Originally Posted by Sketchy
Scrap the last two lines and add this:

+ Always
-> Set Angle of Flak Cannon to: Angle( "flak cannon visPart" )+Max(Min((((ATan2(Y( "flak cannon visPart" )-YMouse, XMouse-X( "flak cannon visPart" ))-Angle( "flak cannon visPart" )+540) mod 360)-180), 1), -1*1)


This formula and others can be found here: http://www.sketchy.co.nf

Thank you.. this was very helpful.

 
[Signature][/Signature]
   

Post Reply



 



Advertisement

Worth A Click