Discord
Login
Community
DARK THEME

easing the variable makes it freak out

easing the variable makes it freak out

init = function()
  x = 1
end

update = function()
  x *= 0.9
  print(x)
end

draw = function()
end

the intended function is for it to progressively slow down until it reaches zero. instead it kinda freaks out. run the code to find out for yourself

I ran your code, at some point the variable becomes so small that it gets printed with exponential notation, such as 9.95882012880246e-15 ; is that what you call freaking out? It's normal, 9.95882012880246e-15 is 9.95882012880246 x (10 ^ -15) :-)

Oh. Yeah, but can i make it go to zero? I was using this in a platformer game but instead of stopping the player slowly slides forever and doesn't slow down

Maybe set a minimum limit after that it stays at 0.

update = function()
  if x>0.01 then
    x *= 0.9
  else
    x = 0
  end
  print(x)
end

Or so :)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community