Object.Platform.MovingAngle resets to 0?

0 favourites
  • 11 posts
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • is there any way to maintain the moving angle of an object when it's speed is 0, as of right now the moving angle resets to 0 when the object isn't moving...

  • I don't understand exactly what you mean. How you move the object, with behavior or events? In any case, you could store the angle in a variable.

  • maybe this

    Object speed <= 3 or something small - set angle "Object.angle"

  • maybe some pseudo code might help, I'm using Platform behaviour and this is what appears to be happening...

    IF sprite.Platform.Speed = 0 THEN

    sprite.Platform.MovingAngle = 0

    I don't have this coded in, this seems to be happening on its own...

    any ideas?

  • I see, it resets back to 0. I don't think you can do anything about it, there is no "Set moving angle" action.

  • poop

  • And of course, if it's not moving there can't be any moving angle.

    You could keep last moving angle in a variable. On key (left, right)is down > set the variable to (180,0)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The moving angle is calculated as the angle between the position of the object last tick, and the position of the object now. So if the object is not moving, the positions are the same. So what is the angle between two identical points? It just returns 0 in that case.

    You could work around it by storing the angle of motion in an instance variable - if you only set it in an event when the speed is not 0, then you have a variable which is the "last moving angle" which sounds like what you want.

  • wound up using a different system, but thanks for help guys, and the inner workings Ashley!

  • The moving angle is calculated as the angle between the position of the object last tick, and the position of the object now. So if the object is not moving, the positions are the same. So what is the angle between two identical points? It just returns 0 in that case.

    You could work around it by storing the angle of motion in an instance variable - if you only set it in an event when the speed is not 0, then you have a variable which is the "last moving angle" which sounds like what you want.I think this behavior is counter-intuitive for an expression supposed to return the angle of motion. Returning 0 when not moving means that the object angle of motion is pointing to the right, which isn't true.

    Logically it should return "null" when the object is not moving, since there's not an angle of motion when you're not moving. However this wouldn't work for C2 system since it would broke other expressions. So I think returning the last moving angle makes more sense.

    At least for every case I can image that this expression would be useful I would need to implement the work around to get the desired behavior, so I think this should be by default.

  • I tend to agree, for example, if I'm using two different animations for a sprite's left and right movement...

    (e.g Samus' gun being on the correct arm no matter which way she faces in Zero Mission)

    ...then I shouldn't have to create a completely new variable to house the last known MovingAngle. I believe it should remain at whatever it was when it stopped moving, and then only change when the sprite starts moving again.

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