User Tag List

Results 1 to 8 of 8

Thread: Rotate an object towards an angle (stored in an alterable value)

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rotate an object towards an angle (stored in an alterable value)

    Hey guys! Simple question here. I used this formula to rotate an object towards a direction using x and y co-ordinates. Now I can't seem to figure out how to modify this to rotate an object towards a value stored in an alterable value inside the object

    A.angle + Max(Min((((ATan2(A.y - B.y, B.x - A.x) - A.angle + 540) mod 360) - 180), Rotation), - 1 * Rotation)

    I upgraded my level editor to allow you to rotate objects in the game. The objects use the physics engine and auto rotate back to their original angles if disturbed. Or they are supposed to. I just need a formula that compares the objects current angle to the one stored in the alterable value and rotates it slowly back to the stored position. Any help would be great! Thanks in advance!

    Here is an example of how it should work with the rotating
    http://gph.is/2jnfkVs

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right now I have all objects auto rotate if they are not at 0 degrees. It is easy to have them auto rotate when not 0 degrees
    ex:
    active object 1 angle <180, set angle to angle -1
    active object 1 angle >= 180, set angle to angle +1

    This only works to rotate objects back to 0 degrees but now my level editor is much more dynamic and I need objects to rotate back to any degree. Having trouble figuring this out. Remember in my game bricks are using physics engine so they will be rotated if hit by an object. I need them to auto rotate back to their starting angle

    attached is a comparison with the old and new editor
    Images attachées Images attachées

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out myself by trial and error. if anyone else needs to know how to do this the formula is

    Angle to rotate = Angle( "Active" ) + Max(Min(( ( ( "angle you want to rotate to" - Angle( "Active" ) + 540 ) mod 360 ) - 180 ), rotation), 0 - rotation speed)

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I attached an example MFA I made for anyone who is struggling with this. It covers

    > Calculating the angular difference between two objects
    > Rotating to a desired angle
    > Rotating towards a position


    Feel free to edit and add more useful formulas to it regarding angles and rotations please and thank you
    Attached files Attached files

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleFirefly 3D Module
    aenever's Avatar
    Join Date
    Jun 2013
    Posts
    1,554
    Mentioned
    34 Post(s)
    Tagged
    0 Thread(s)
    Wow that's super helpful thanks

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am glad someone found a use for it

  7. #7
    Clicker Fusion 2.5Android Export Module
    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)
    amiman99's Avatar
    Join Date
    Dec 2015
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many Thanks, need it something like that just now, and modified it to use touch control coordinates.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    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)
    Nicholas Martin's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome dude. Glad it helped

Similar Threads

  1. Rotate to angle
    By willy in forum Fusion 2.5
    Replies: 0
    Last Post: 28th March 2014, 08:08 PM
  2. Rotate (angle) vs animation on iDevice
    By loglady in forum iOS Export Module Version 2.0
    Replies: 5
    Last Post: 2nd August 2012, 04:50 PM
  3. Help Please... Need to Rotate Rotate object with a wheel
    By Tuna in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 12th February 2012, 04:48 PM
  4. Rotate to angle
    By wizkidweb in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 6th May 2008, 12:03 AM
  5. rotate to an angle example
    By LazyCoder in forum File Archive
    Replies: 3
    Last Post: 20th September 2006, 04:49 AM

Posting Permissions

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