Impart movement to an object with a kinematic object

Trying to hit a ball around with a kinematic box doesn’t seem to work as I expect. If I change the position of the box so it hits the ball, it doesn’t impart movement to the ball - the ball just moves out the way.

Let’s say I have a ball at (3,0,0) and a box at (0,0,0). How could I go about saying, “move the box to (2.5,0,0) so it hits the ball,” and have the ball roll away as if hit by a box travelling 2.5 units in a frame? I’ve tried all sorts of solutions such as tracing a ray from the box’s start pos to the collision point and imparting a force, and all have some success but also some issues (like box passing through ball).

It seems a really simple problem naturally suited to physics, but I can’t solve it!

Applications could be pinball, or a golf type game.

A kinematic object doesn’t have any momentum. When it touches something there’s no momentum to transfer. It’d be like your mouse cursor hitting something. Don’t use a kinematic object like that, it defeats the whole point of having physics.

Even using a non kinematic doesn’t work properly. Okay, it does start the ball rolling, but the collision lacks the same impulse of a collision with a rigidbody under motion within the energy. It looks like the cube collides and the ball is repositioned to the this collision point on the box in its new position. Then there’s a bit of rolling. A fast displacement of the box into the sphere doesn’t send it flying, unlike an applied force. A fake can be made applying an explosion force at the point of collision, but that’s kinda hacky. Is there no way to set a rigidbody’s forces and momentum based on deltas since last frame? So if it’s been moved using Rigidbody.MovePosition(), it has the same momentum at the end of that movement as a force applied to it to move it that delta since the last frame?

Here’s how this normally works in physics engines. Colllision in one dimension between two bodies (1 and 2) before (b) and after (a) a collision:

m1b * v1b + m2b * v2b = m1a * v1a + m2a * v2a

This is momentum conservation and how it works in reality.

If one of your objects that you’re moving has velocity 0 because no forces have acted on it, then that body’s velocity is likely 0 even if you manually move it from position A to position B with translate or something. If that’s the case, then no matter how fast you’ve moved the body, the momentum of that body (it’s mass*velocity) is still 0. So it’s not going to react to a collision correctly, and neither is the object that it hit.

If there are options to get Unity/PhysX to update all this stuff when you’re manually controlling the position, someone else will have to show you how because I don’t know. I’d never dream of trying to run a physics simulation that way. Hopefully someone else that has done it can help you.

If you’re doing it “right” and bounciness doesn’t work the way you want, I think you can change that in the physics material. In reality it’s called a coefficient of restitution, I think in Unity they just call it “bounciness.”

Full bounciness doesn’t create the same impulse as one would expect. A force could probably be applied based on the dragged object’s last position, which I was toying with, but it was again hacky. Not least because on a touch screen the accuracy isn’t great and smoothing that out adds lag.