0 Favourites

Object.Platform.MovingAngle resets to 0?

  • 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)

  • 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!

  • Construct 3

    Buy Construct 3

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

    Buy 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.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)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
How do I reset a game ?
28 2,808
oceldot's avatar
oceldot
Topic
0 Favourites
[REQUEST] Sine action "RESET"
24 5,214
XManBG's avatar
XManBG
Topic
23 1,489
guannstar's avatar
guannstar