# Move value towards 0?

This forum is currently in read-only mode.
0 favourites
• 4 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
• Is there a command that if a value is lower than 0 or greater than 0 it will add/subtract a certain amount. It would be a lot easier than having to make separate events.

• Wow you're lazy.

It just takes 2 events!

• ## Try Construct 3

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

Construct 3 users don't see these ads
• That'd be useful. But since I don't remember implementing such functionality in any game making tool / programming language, this kind of stuff would be hard to fit in.

My code's filled with ugly 3-evented "move value towards 0", Function object would simplify things a little.

• Wiki says that the system expression "sign(x)" returns x/abs(x) for non-zero numbers. That's -1 for negative numbers, +1 for positives. This suggests the following (untested) expression for "move from a given value towards zero by a specified amount":

``````Value-(sign(Value)*Amount)
[/code:1dgemdxb]
Note that this will "overshoot" zero if abs(Value) < Amount; e.g. with Value=1, Amount=2 you get -1.``````