User Tag List

Results 1 to 6 of 6

Thread: Detect if Angle is facing left or right

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detect if Angle is facing left or right

    Im 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

    How can i do this?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    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)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first steps to coming up with an algorithm is to define the results you want for a few different situations and then generalise:
    What is the scope of your Angle? Eg 0-31 (like an objects Directions) or 0-359 like an objects angle?
    Also do you want everything from dir 9 to 24 to be Left and 0-8, 25-31 to be right (or for object angle: 91-270=left and 0-90, 271-359 to be right) or are you just dealing with directions that are 16 or 0 (or 180 and 0 for angles) inwhich case just use direction/16 to get 1 for left and 0 for right (or angle/180)

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    'Angle / 180' returns 0 for UP and 1 for DOWN.
    I need it to return 0 for RIGHT and 1 for LEFT, or the other way around.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using 360 degree direction system ( 0 -359 ).

    'Angle / 180' returns 0 for UP and 1 for DOWN.
    I need it to return 0 for RIGHT and 1 for LEFT, or the other way around.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ((Angle + 90) mod 360) / 180

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

    Modulus gives the remainder of a division operation. In practice it makes a value "loop" around, so you can offset your angle and still have it be in the 0-360 range. For example:
    370 mod 360 = 10
    350 mod 360 = 350
    360 mod 360 = 0
    540 mod 360 = 180
    etc.

    http://en.wikipedia.org/wiki/Modulus_operation

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Jul 2006
    Location
    Lacey, WA
    Posts
    756
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I Mod, so very useful! I use it everywhere \/

    (XMiliseconds Mod 1000) = Seconds, (XDays Mod 7) = day of the week, etc

Similar Threads

  1. How to detect dragging left with multitouch object
    By kungsangun in forum Android Export Module Version 2.0
    Replies: 1
    Last Post: 20th June 2013, 09:26 PM
  2. Is Angle facing Left or Right?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 16th October 2012, 09:09 PM
  3. How to set object angle so that it is always facing the mouse cursor
    By AnD4D in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 17th May 2012, 09:39 PM
  4. Vector Movement - How to detect angle of wall?
    By Strife in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 30th September 2010, 12:15 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
  •