First steps in Construct - Retrieving N Angles

This forum is currently in read-only mode.
  • Yep, Construct is awesome! But since I'm a newbie I'm having my share of problems accomplishing some (probably?) simple things - like ANIMATIONS.

    Well, dang! After searching some more, I've found the anser in the forum - enable Animator Bar!

    Nevermind, but thanks anyway!

    ...

    OKAY: Since this thread became useless how about another question?

    It's possible to make objects rotate step-wise (N Angles setting). Is there a way to retrieve that step angle? The normal angle value still returns a value between 0-360. Any ideas? THANKS!

  • You can do it with math.

    a/n = N Step

    Where a is the actual angle of the object and n is the number of angles in a step.

    For instance, if your N Angles is set to 4 then the number of angles in each step is 90. If your object is at 270 degrees then:

    270/90=3

    Your N Step is 3.

    If your N Angles is 8 then the number of degrees per step is 45. If the angle of your object is 225 then:

    225/45=5

    Your N Step is 5.

    The result is zero-based so if your object is facing right, your N Step will be 0. So for an N Angles of 4, you'd get steps of 0, 1, 2, and 3.

    It seems to me it would be easier just to compare the actual angle of the object, though.

  • Thanks! I tried this, but I can't get it to match with the actually displayed angle, the value seems off. When facing right, the value can be both 0 and 3.

    More details: I'm using the RTS movement and want to check what N angle (using 4 steps) is currently displayed.

  • Just make your own compare and set a variable based on that. With N Angle of 4 you know that the only actual angles your sprite can be facing are 0, 90, 180, and 270. So do this:

    + sprite.Angle Equal to 0
      - set sprite.Value('nStep') to 1
    
    + sprite.Angle Equal to 90
      - set sprite.Value('nStep') to 2
    
    + sprite.Angle Equal to 180
      - set sprite.Value('nStep') to 3
    
    + sprite.Angle Equal to 270
      - set sprite.Value('nStep') to 4
    [/code:3kgbais7]
    
    And if your sprite angle = 360 then manually set it to 0.
    
    But like I said before, it would be easier to just compare the angle directly.  You're just making an extra step for yourself by translating it into a single digit.  I don't see the point in it (unless you have a really good reason).
  • Using a mix of what was suggested by deadeye and my own approach, I got this ... it may not be what you're trying to get, but I gave it a shot.

    http://www.mediafire.com/?dmlge0yn2tj

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • deadeye: Thanks, but when using the RTS movement, the angle can be anything between 0 and 360, not just the 4 steps, so comparing like that won't help much (that was the first thing I tried).

    Jeswen: That seems to work just fine. Thanks!

  • deadeye: Thanks, but when using the RTS movement, the angle can be anything between 0 and 360, not just the 4 steps, so comparing like that won't help much...

    Now I'm confused. What am I missing here? Does N Angles not work with RTS or something? (I haven't been able to test anything because my girlfriend has been on my computer literally all damn day )

  • The object displays the N angles properly but the angle value does not return the actual N angles, you get the whole 0-360 spectrum instead. Might be because of the RTS movement.

  • Okay, so... if you set N Angles to 4 on an RTS object, it can only face in four directions, right? That would be 0, 90, 180, and 270. Is that what's happening?

  • Yep, the facing only in 4 directions works, but if you try to get the angle you get anything between 0-360 depending on the angle of the RTS movement.

  • Doh! Okay, I get what you're saying now. I was finally able to get on Construct just now and test it out. I see now that N Angle is only a visual trick, the actual angle is still a full range of degrees.

    That's really weird and counter-intuitive. I totally didn't expect it to behave that way, that's where I got confused. It seems to me that if you're locking the rotation to a set number of steps, it should only return those step values.

    It's also strange to see your sprite display at exactly 180 degrees, but be told that it's really 185.9408654 degrees. It's like the angle of motion is tied into the angle, and it doesn't need to be.

    Edit:

    Just checked out Jeswen's .cap. Pretty clever solution. Just an fyi though, you don't need to have an Always event on every line, it works just as well this way:

    <img src="http://xs226.xs.to/xs226/08155/always299.jpg">

  • Bad habit from MMF2 when I encountered things that needed "always" hehe. I didn't even bother to see if they worked without it!

  • Bad habit from MMF2 when I encountered things that needed "always" hehe. I didn't even bother to see if they worked without it!

    Yeah... slowing down the applications >:( , microsoft have the same strategy .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)