Actor Facing Direction

PaxPaxPaxPax Member Posts: 106
I am struggling with this easy issue and have finally decided to let my bruised ego ask for assistance. I have a clock. The small arm of the clock rotates with a touch behaviour. I cannot figure out how to detect when the small are is facing numbers on the clock. For instance, I would like the sound 'three o'clock' to play when the arrow/small arm is facing the three and so on for each number. How do I detect where the arrow/small arm is facing.

Thanks and cheers!!!

Best Answer

  • SocksSocks London, UK.Posts: 12,822
    edited March 2013 Accepted Answer
    @PaxPax
    if self.rotation is 90 (for example) than play sound..... to no avail.
    I guess because you are making a clock your arms are going clockwise (axiomatically!) - so in GameSaladLand™ going clockwise is actually decreasing the angle (counterintuitively counterclockwise counts up in positive value / clockwise counts down) . . . so:

    12:00 is 0°
    3:00 is -90° (or +270°)
    6:00 is -180° (or +180°)
    9:00 is -170° (or +90°)



    I've made you a quick demo:

    http://www.mediafire.com/?6jx4i7c92ah694t

    . . . .

Answers

  • SocksSocks London, UK.Member Posts: 12,822
    I am struggling with this easy issue and have finally decided to let my bruised ego ask for assistance. I have a clock. The small arm of the clock rotates with a touch behaviour. I cannot figure out how to detect when the small are is facing numbers on the clock. For instance, I would like the sound 'three o'clock' to play when the arrow/small arm is facing the three and so on for each number. How do I detect where the arrow/small arm is facing.

    Thanks and cheers!!!




    3 o'clock = 270°
    6 o'clock = 180°
    9 o'clock = 90°
    12 o'clock = 0°
  • PaxPaxPaxPax Member Posts: 106
    edited March 2013
    3 o'clock = 270°
    6 o'clock = 180°
    9 o'clock = 90°
    12 o'clock = 0°


    Woh, now my ego is really bruised. :(
    I should have articulated my question in a more concise manner. What is the 'code' for the arm/arrow to recognize its rotation degree---3 o'clock or whatever. I tried...

    if self.rotation is 270 (for example) than play sound..... to no avail.

    thanks again and as always, Socks, thanks for making me LOL
  • PaxPaxPaxPax Member Posts: 106
    Thanks @socks---finally worked. It was one of those weird out of body experiences as I had played round with 'negative' degrees, clock wise and counter clock wise etc. The attribute to set self rotation back to zero really helped!!! I am sure I would have forgotten to do that as well.

    Thanks again,
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    The attribute to set self rotation back to zero really helped!!! I am sure I would have forgotten to do that as well.
    It's a rule rather than an a attribute. [/pedantry] :(|) 8-X :P

    There's probably a more efficient way you could do it without that extra rule - (maybe using %360 ?) - but the demo should hopefully give you a few pointers.
  • PaxPaxPaxPax Member Posts: 106
    Yes, as you say it is an attribute. However to continue with this pedantic behaviour, in this case it is an attribute within a rule. Am I forgiven for me unscholarly or informal communication? @-)
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Yes, as you say it is an attribute.
    No, I said the very opposite, I said it's a rule rather than an attribute. :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Here is a fun formula that will give you the hours:
    floor((12-(self.Rotation-90)/30)%12)

    And here is one for minutes:
    floor((60-(self.Rotation-90)/6)%60)

    Note: the clock hands should point to 0 degrees when drawn --->
Sign In or Register to comment.