Is rotating?

This forum is currently in read-only mode.
  • Ok so after seeing linkman's awesome replay example, I've been working on ways to streamline the idea into a less cpu hungry method. So far my best effort is only recording the changes over time rather then every single frame etc

    for example: at 1000 milliseconds user presses W, at 2034 user releases W

    And then when playing back the replay, I let my engine play out my keystrokes just as I pressed them.

    So far it works real great with keystrokes.

    I've hit a bit of a snag though, I'm using 'always rotate object 360 * timedelta towards the mouse', the only problem is, I'm having a lot of difficulty testing to see if the object is turning.

    (It's a custom movement obviously)

    The ideal way i'd LIKE to have it is something like this (pseudocode)

    1005 milliseconds, user starts left turn

    2400 milliseconds, user ceases left hand turn

    As I'm using an always event that rotates the sprite, Is there any way of testing the rotate state of the sprite? ie: Static, Turning left, Turning Right

    If i was using the keyboard for turns it would be no problem, but i'd rather use the mouse to aim.

    A 'Rotate towards angle' system action would be really handy but I don't know if it would entirely solve my problem

    Any ideas?

    Have I explained the problem adequately?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You might be able to get away with an angle compare. Something like:

    sprite.Angle is greater than sprite.Value('lastAngle')

    You'd have to compensate for the 360/0 boundary though by adding in some more complex checks:

    +round(sprite.Angle) is greater than sprite.Value('lastAngle')
    +round(sprite.Angle) does not equal 360
       ->Set sprite.Value('rotDir') to "right"
    +round(sprite.Angle) = 360
    +sprite.Value('lastAngle') = 0
       ->Set sprite.Value('rotDir') to "left"
    +round(sprite.Angle) is less than sprite.Value('lastAngle')
    +round(sprite.Angle) does not equal 0
       ->Set sprite.Value('rotDir') to "left"
    +round(sprite.Angle) = 360
    +sprite.Value('lastAngle') = 0
       ->Set sprite.Value('rotDir') to "right"
    +round(sprite.Angle) = sprite.Value('lastAngle')
       ->Set sprite.Value('rotDir') to "stopped"
       ->Set set sprite.Value('lastAngle') to round(sprite.Angle)[/code:2wgbui6z]
    Then you could record the 'rotDir' states and use those for the playback.  I haven't tested it but with some tweaking it might do what you need.
  • Yeah after I posted I tried doing pretty much exactly that idea, although i didn't go nuts with the 0-360 thing cause really it wouldn't be noticed so much in the game (hopefully)

    It seems to test ok, but I haven't tried it out in replay yet as it was 1:30am here when I thought of it.

    I have yet to test it out in replay but I did think for a moment, even though the code turns the player at precisely at 360 * timdelta, when holding forward, you can get the player to do an elliptical orbit around the mouse, which means that the player -looks- like it is rotating slower when it is still rotating at 360 per second but stopping and starting at tiny intervals. The problem with this is that using the last angle system, it just comes up as 'turning left' (or right depending) the whole time, because the current angle is different to lastangle but it's turning slower than 360 * timedelta technically

    It's hard to explain, basically, I haven't tried it but i can tell that if i tell the replay to turn left at this point whilst going foward, it will turn a lot faster than what happened in real time.

    Not too sure how anyone can fix this, just throwing it out there. It is a bit hard to record something like this without doing every tick anyway

    Nothing like a good challenge

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