actionscript physics stopper
Out of context: Reply #2
- Started
- Last post
- 12 Responses
- unknown0
Well it's like this:
Since you already know that inertia divides the difference between the target distance and the object's current position the formula actually keeps dividing the next value over and over. That's how you get that slowing down effect. Well if you understand this then it becomes obvious that since we are dividing, it will be impossible to get to absolute zero. It will always have the decimals.
Now enough of theory, let's take a look at your case. So let's say you have an object that needs to stop at X:380. The formula does its thing and gets to almost near 380 (but never exactly). In this case you need to use math.round() or math.abs() in order to round the decimal number in order to use IF loop. I just can't remember which one exactly since I don't have a reference here. There is a math function that round to the nearest higher number. That's how you test to see if your object reached the targeted point. I've done this many times, and I can try to find a script in one of my projects if you can't solve it yourself.
Cheers.