# Thread: Rotate Active Based on Mouse Position

1. ## Rotate Active Based on Mouse Position

In Fusion, for some reason moving using angles is counter clockwise, but ATan2 is clockwise which make the mouse angle movement mirror itself.
Does anyone know how to fix this?

I want the rotating active ship to move and rotate around based of the mouse position.

Rocket Game Proto.mfa

2. Fixed

Thanks to OKAsti from the Zentaco Productions Discord. https://discord.gg/WKbrG9q

3. I know you said it's already fixed, but for anyone else who wants to know on what to do to fix:

Change:
- Always -> [Rotation] -> Set angle to ( ATan2(XMouse - X( "Enemy Ball" ), Y( "Enemy Ball" ) - YMouse) + 360 ) mod 360

to this:
- Always -> [Rotation] -> Set angle to ( ( ATan2(XMouse - X( "Enemy Ball" ), Y( "Enemy Ball" ) - YMouse) + 360 ) mod 360 ) * -1

Basically, I added ()'s in all the math, and then a * -1 at the end of that.

4. You've mixed up x and y in the atan2 function.

Simply try ATan2( Y - Y2, X2 - X )
...where X and Y is the position of the object, and X2/Y2 is where you want the object to look at.

Saying this for reference when someone else comes across this thread (which is why I'd be neat if you said what fixed it).

5. Do you guys know if there's a heads up about the most practical geometrical math expressions that can be used in game design, especially for creating complex movement patterns? I know there are dudes out there who basically calculate everything (for example boss creature limbs) using sin and cos expressions and I would love to learn this too. Also, are there more functions like ATan2 out there, which are of highly practical (every day) use? Besides using ATan2 I only know how to calculate distances and got a simple sine wave movement to work, but that's about it.

6. I highly recommend this: MATH: How I stopped worrying and learned to love the Expression Editor (\$0.99 on the Clickstore). It sounds like exactly what you want, Julian.

As it happens, I just went through it myself last night (despite buying it months ago). The earlier sections are pretty basic, but towards the end it gets into some really cool examples with trigonometry, easing, and bezier curves. The snake movement is incredible!

7. Thanks, man! I didn't know this existed, will buy it today! I also found a nice set of tutorials on game math on youtube, it starts pretty basic, which is good for a dude like me :P https://www.youtube.com/user/BSVino

edit: I had a quick first look at the Clickstore tutorial, exactly what I was looking for, many thanks again!!

edit2: This stuff is insane, didn't even know things like this are possible with Fusion!

8. Here's a better version.

( ATan2(XMouse - X( "Enemy Ball" ), Y( "Enemy Ball" ) - YMouse) ) * -1

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•