# expression floor how use this?

0 favourites
• 9 posts
From the Asset Store
************ 2D top down floor spikes **************
• how i can use this expression   i adding to variable 'floor(0.1)' and my variable still show 0 even if i add 20 times this number

I want something like that:

when i add to variable 0.9 i see 0 but when i add again i see 1

right?

• floor(0.1) = 0

so if you add 0 the variable stays the same.

you should probably just add 0.1 to your variable and when you want to use the variable anywhere, use floor(variable) so when variable is 0.9 it will return 0 and when the variable is 1 or 1.1 etcetera it will return 1.

• floor() design is to round the value down.

ciel() designed to round the value up

round() designed to go to nearest.

so

floor(0.9) = 0

floor(1.8) = 1

floor(0.1 * 20) = 2

floor(0.1) * 20 = 0. Math done in brackets or functions are done first

ciel(0.9) = 1

ciel(1.8) = 2

ciel(0.1) = 1

round(0.9) = 1

round(1.8) = 2

round(0.1) = 0

• LittleStain   and jayderyu can you check this? dl.dropboxusercontent.com/u/44710358/floor.capx

i must do something wrong because when i adding many times 0.1 to my variable, variable ALWAYS show 0 !

• You're adding floor(0.1) or 0 to the variable so it won't ever change.

Just add 0.1 to your variable and set the text to floor(variable1) to do what you want.

• R0j0hound got it :). I would consider R0j0 our community math export :)

• R0j0hound got it :). I would consider R0j0 our community math export :)

expert*

• Actually after re-reading the previous posts I realize that my post is redundant because LittleStain said the same thing before me. My apologies.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• rojohound No apologies needed, sometimes the way it's written helps the reader more than the message itself.

Your comments and explanation of using math in Construct2 have helped many, myself included, so in my opinion a comment by you is never redundant.

• 9 posts