Speed, Distance and # of steps

J

JohnG

Guest
I don't think I'm understanding the relationship between the speed variable and step instance and how I use these to calculate how many steps an object will take in order to cover a known distance. Here's an example of something I've been tinkering with.

speed = 3
distance = 24 (pixels)
# of steps = distance / speed

My assumption is that the number of steps the object will take equals the distance divided by speed. Given the data above an object will take 8 steps to cover a distance of 24. But I don't think that's correct.

For more context, I have a counter that decreases while an object covers a specific distance. I want that counter to reach zero once the entire object has completed the distance, but the math isn't coming out to zero. I also suspect I'm not accounting for the the width of the object and I should be.

Any ideas?
 

NightFrost

Member
No, you are understanding speed correctly. It is pixels per step. At speed 3, it takes 8 steps to cover 24 pixels.
 

Joe Ellis

Member
Yeah thats completely right, if the experiment is making different results your making that wrong, you cant argue with a calculator, 24 / 3 always equals 8
 
There's a number of things that might be going on depending on what you're doing exaclty. The thing that seems most likely to me is that you aren't counting in a consistent way. For example, you might be beginning your count only after the instance has already moved one step but while assuming it hasn't moved yet.
 
Top