User Tag List

Results 1 to 5 of 5

Thread: Determining the difference in angles

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Oct 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Determining the difference in angles

    Mind me if this is an easy thing, I'm still not very good with angles and math to this day.

    I have an object that turns at different speeds, and it's supposed to be based on how closely it's looking at a point. For now I'll say that it uses an alt.value for this, it turns slowly if it's 1, moderately if it's 2 and quickly if it's 3. I also have it set up that it turns right if these values are positive (1, 2, and 3) and turns left if they're negative (-1, -2, and -3). No turning takes place if it's 0.

    How would I go about determining what value to use in an event? I'd like it to switch to 1 (or-1) if it's nearly looking at the target, 3 if it's almost looking the opposite direction, and 2 for in between. I can get it to turn towards the point, but I can't figure out how to make ranged based on this information.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    I would suggest using this short and elegant formula to get the angular difference
    between the player aiming direction (angle_curr) and target position (angle_dest):

    Atan2(Sin(angle_dest - angle_curr),cos( angle_dest - angle_curr))


    this will give you signed angular difference in the range -180 +180, let's call it "ang_diff"

    then you can simply add: (ang_diff/abs(ang_diff)) / 10.0
    (or any "weighting" modifier that suits your needs)
    to player angle, to have him gently rotate towards destination, faster if he is further from target angle

  3. #3
    No Products Registered

    Join Date
    Dec 2016
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could use a curved interpolation formula to make it smoothly transition from fastest to slowest turning based on angle difference. Does Ctf have a built in interp? if not you can write your own formula for it (though thats a bit of a pain for non-math fans)

    But if you can do that then you dont need to have different speed settings if your goal is to swing the turret smoothly into line.


    Sent from my iPhone using Tapatalk

  4. #4
    Clicker Multimedia Fusion 2

    Join Date
    Oct 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    I would suggest using this short and elegant formula to get the angular difference
    between the player aiming direction (angle_curr) and target position (angle_dest):

    Atan2(Sin(angle_dest - angle_curr),cos( angle_dest - angle_curr))


    this will give you signed angular difference in the range -180 +180, let's call it "ang_diff"

    then you can simply add: (ang_diff/abs(ang_diff)) / 10.0
    (or any "weighting" modifier that suits your needs)
    to player angle, to have him gently rotate towards destination, faster if he is further from target angle
    I understood this well enough to make use of it for what I needed it for. Thanks!

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Glad it was useful,
    btw, I meant:

    add: ang_diff / 10.0

    and not:

    add: (ang_diff/abs(ang_diff)) / 10.0

    ...which would add very small amounts!
    (sorry, I mixed two ideas together while typing )

Similar Threads

  1. Difference between 2 Angles ( through expression)
    By King_Cool in forum Fusion 2.5
    Replies: 11
    Last Post: 30th November 2015, 03:51 PM
  2. Replies: 4
    Last Post: 2nd July 2012, 08:05 PM
  3. Determining objects not in order
    By Captain825 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th March 2010, 08:26 PM
  4. determining distance
    By delusan in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 27th April 2007, 07:31 PM
  5. determining which palette you're using
    By FormerTGFGuy in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th August 2006, 01:02 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
  •