Jump to content

Expressions with Remainders


dchristo

Recommended Posts

I'm trying to write an expression to move a piece of media in increments of 10 pixels.  Given a variable of 0-10, I would like output of 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100. 

The expression I think should work is:

 

(variable - (variable % 1)) * 10

 

I'll be ramping the variable, so I need to remove the decimal porition.  The (variable % 1) should return only the decimal portion of the variable, and subtracting it from itself should give me integers only.

 

I'm using this expression in the X axis of a position tween, and when I set the variable to 7.6, the tween is being set to 76 pixels, whereas I'm expecting it to be 70.  Is this a bug, or am I misinterpreting how the % operator should work?  Is there another way to accomplish this?

 

Watchout 6.1.5 Production (haven't tried on a display), Win7

 

Thanks,

 

--D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...