Hi
I'm using the physics library but my problem is I don't know how long it takes for the object to move to it's destination. Does anyone know the formula for this?
If I have friction 0.25 then how much force I need to apply to the ball so it has traveled 300 pixels in two seconds?
time = distance/speed
The problem is that the rigid bodies in love.physics do not move with a constant speed especially when collisions and damping are involved.
Like I said in my previous post, you need to find a better way to move your bodies, such as a mouse joint, applyForce or applyImpulse.
Thanks I got the time formula but that was not my question
ivan wrote: ↑Fri Sep 27, 2019 12:32 pm
The problem is that the rigid bodies in love.physics do not move with a constant speed especially when collisions and damping are involved.
Yes but I only need to know straight movement
ivan wrote: ↑Fri Sep 27, 2019 12:32 pm
Like I said in my previous post, you need to find a better way to move your bodies, such as a mouse joint, applyForce or applyImpulse.
The "direction" of the movement is irrelevant.
If you have damping and friction then the body is not moving at a "constant speed".
Why do you need to estimate the time of arrival?
You don't need to know the time - but it would help if you knew the distance to target.
Just keep applying the force until the ball is "close enough" to the target.
Mouse joints are usually the better option.
How much force to apply depends on how much acceleration you want and how much does the object weighs.
F = m / a
Damping simply applies a force like this but in direction opposite to motion direction. Assuming that direction vs force angle mismatch isn't very important, you can simply increase desired acceleration by this value in the above formula. You will get a force that fully counteracts damping and then provides desired acceleration.
The slow down effect of the ball would be nice, not just applying more force
Your body already has damping so it should "ease" to a stop by itself.
One hacky approach could be to make the force proportional to the distance:
force = min(easing/distance, 1) * force
where "easing" is the distance you want the object to slow down.
You may have to adjusting the damping too.
raidho36 wrote: ↑Fri Sep 27, 2019 6:16 pm
How much force to apply depends on how much acceleration you want and how much does the object weighs.
F = m / a
Damping simply applies a force like this but in direction opposite to motion direction. Assuming that direction vs force angle mismatch isn't very important, you can simply increase desired acceleration by this value in the above formula. You will get a force that fully counteracts damping and then provides desired acceleration.