Determine distance with velocity * time?
Hello everyone,
I was trying to set up a simple distance calculator based on the formula of velocity*time to find the accumulative distance of a traveling object.
My current set up is almost effective except for one a weird bug that I can't seem to work around.
I have a game attribute called distance traveled. I have a actor that displays the text for distance traveled so I can watch it count. That game attribute is then constrained to another (actors velocity*time).
Something else, the most important thing you should know, the other actors velocity is capable of changing radically and the actor has the physics.drag attached to it so that it will slow down when not accelerating.
So it looks like:
Constrain
game.distanceTraveled to actor.motion.velocity.x*game.time
So, whats the problem? Right? This works great... EXCEPT... that whenever this actors velocity declines, as in it stops actively accelerating, the total on my distance calculator stops adding and starts subtracting.
I need drag turned on so the object will slow down, so deactivating drag is not really an option.
Any thoughts?
Thank you much!
I was trying to set up a simple distance calculator based on the formula of velocity*time to find the accumulative distance of a traveling object.
My current set up is almost effective except for one a weird bug that I can't seem to work around.
I have a game attribute called distance traveled. I have a actor that displays the text for distance traveled so I can watch it count. That game attribute is then constrained to another (actors velocity*time).
Something else, the most important thing you should know, the other actors velocity is capable of changing radically and the actor has the physics.drag attached to it so that it will slow down when not accelerating.
So it looks like:
Constrain
game.distanceTraveled to actor.motion.velocity.x*game.time
So, whats the problem? Right? This works great... EXCEPT... that whenever this actors velocity declines, as in it stops actively accelerating, the total on my distance calculator stops adding and starts subtracting.
I need drag turned on so the object will slow down, so deactivating drag is not really an option.
Any thoughts?
Thank you much!
Comments
Currently, all you're doing is multiplying two numbers. For example, let's say I run an ice cream parlor. I sell 1 cone at $2 to my first customer and 1 cone at $2 to my second customer. How much money have I made up to this point?
According to your calculation, I've made a total of $2.
If you want an accumulated amount, add the first and second sale together:
1st @ $2 + 2nd @ $2 = $4
I could work out the function you need for you, but you're on the right track and I'm confident you can figure it out from here.
I see what your getting at and now I think I understand the error in my function a bit better. I'm constrained to something that is not accumulating but only multiplying.
Thanks for the insight.
I set up a temporary but also performance heavy alternative for anyone interested. I have a series of actors across the screen with the collide behavior adding up my distance as another actor wraps across the screen.
Crude but effective...
I will prefer to get the math function operational instead.
Thanks again.