Object.Platform.MovingAngle resets to 0?

Get help using Construct 2

Post » Tue Nov 15, 2011 5:42 pm

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...
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Tue Nov 15, 2011 6:41 pm

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.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Nov 15, 2011 6:44 pm

maybe this

Object speed <= 3 or something small - set angle "Object.angle"
B
19
S
3
G
3
Posts: 56
Reputation: 2,496

Post » Tue Nov 15, 2011 7:34 pm

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?
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Tue Nov 15, 2011 7:57 pm

I see, it resets back to 0. I don't think you can do anything about it, there is no "Set moving angle" action.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Nov 15, 2011 7:58 pm

poop
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Tue Nov 15, 2011 8:01 pm

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)Noga2011-11-15 20:09:55
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Nov 15, 2011 11:02 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Nov 16, 2011 12:21 am

wound up using a different system, but thanks for help guys, and the inner workings Ashley!
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Wed Nov 16, 2011 5:49 pm

[QUOTE=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.[/QUOTE] 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.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Next

Return to How do I....?

Who is online

Users browsing this forum: Draconinho, luisgmolina, Magistross, nedzad, nimos100, R0J0hound, Rezzon71 and 27 guests