User Tag List

Results 1 to 5 of 5

Thread: Making and Matching Angles

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    May 2015
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Making and Matching Angles

    So I need to find the angle of an object relative to another object. I learned through browsing the forums that I should use "Arc tangent of y/x", which does work. It gives a range of 360 numbers starting at -180 and ending at 180. I want all of that to be positive, so I simply added 180 to it so it's now between 0 and 360, just like an Active's angles. Unlike that though, 0 is facing directly left, instead of directly right. I've tried adding and subtracting 180 and 360 in various places, using the NOT function, but I don't get the results I want. Is there a way to fix this, or should I just keep going and find other workarounds later down the line?

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,736
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Don't understand what you want, but here is a couple of formulas:

    Detect If Angle Is Facing Left or Right -
    Q: You are looking for a way to detect if an Angle is facing left or right through an expression. For example, return 0 if Angle is facing right, return 1 if Angle is facing left.
    Solution:
    ((Angle + 90) mod 360) / 180


    This will return 0 for right and 1 for left like you want.


    Getting the Angle Between Two Points -
    Using atn2()
    atn2(X2-X1, Y2-Y1)


    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    May 2015
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nivram View Post
    Don't understand what you want, but here is a couple of formulas:

    Detect If Angle Is Facing Left or Right -
    Q: You are looking for a way to detect if an Angle is facing left or right through an expression. For example, return 0 if Angle is facing right, return 1 if Angle is facing left.
    Solution:
    ((Angle + 90) mod 360) / 180


    This will return 0 for right and 1 for left like you want.


    Getting the Angle Between Two Points -
    Using atn2()
    atn2(X2-X1, Y2-Y1)


    Marv
    Yeah, I should've been more specific. Here's a picture detailing what I currently have. Explaining Angles.jpg

    Ignore this fact, but I'm making a 3D game. I need to "slide" wall graphics across the screen, and in order to make it look realistic (or even plausible) I need both the player's angle, plus the wall's angle in relation to the player (a-la using trigonometry and sine and cosine and whatnot). In the picture, if you add 1 to either angle, doesn't matter, they both rotate the same way, but 0 degrees is on the right for the Player, and 0 degrees is on the left for my calculation.

    BUT

    Halfway through typing this response, I was looking over yours, and I noticed that you said the formation was X2-X1, Y2-Y1. The secondary object (in this case my wall collision object) goes first, I had these values flipped around, and I had no idea that was the case. I went and flipped them back around so the wall went first and now they both are angled the same way with 0 degrees oriented in the same spot. Thank you for your help, and thank you for enabling me to try stupid things for my own amusement.

  4. #4
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    668
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    You had it right the first time. To get the angle between two objects is Atan2(Y2 - Y1, X1 - X2). Nivram's version is incorrect. If your 0 was left instead of right, you need to swap object 1 and object 2 around in your formula. Actually, reading your post again, you add 180 to the output. This will flip your result, not make it 0-360. Instead, set the output to (output + 360 ) mod 360.

    atan2.mfa

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    May 2015
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Actually yeah, that's exactly what I needed, lots of decimals for as much precision as I can get too. Thanks a lot!

Similar Threads

  1. Grouping objects for a matching game
    By mailalon in forum Fusion 2.5
    Replies: 7
    Last Post: 17th November 2015, 03:15 PM
  2. Replies: 4
    Last Post: 2nd July 2012, 08:05 PM
  3. Problem with duplicate enemies matching ID with..
    By DaveC in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 27th July 2011, 11:50 AM
  4. Matching up enemies with their own active objects
    By alxmrg in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 8th July 2010, 11:27 PM
  5. Random Positions(Matching game)
    By themadhatter in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 5th February 2010, 01:44 PM

Posting Permissions

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