Passing Control From Script to PhysX

I need to launch a ball at a target and, based on the physics of the launch parameters, have the ball hit the target at a particular location. Ideally, I’d like the physics engine to handle this, but PhysX is not up to the task. When launched with an impulse, the ball DOES NOT hit the target where it should, and its errors do not vary consistently with launch parameters, which means they can’t easily be compensated for.

It seems I should be able to control the ball’s motion via script (MovePosition), then upon collision with the target, hand off control to PhysX to control the subsequent bounces. But I’ve spent LOTS of time on this, and just can’t get it to work.

Has anybody ever tried this before, or am I the first? If you’ve ever successfully switched between script and PhysX control, please let me know how you did it. If there’s some sample code somewhere I’ve not been able to find, please point me in the right direction. Thanks.

I might have missed some subtlety in your scenario, but isn’t it just a matter of toggling the RigidBody’s IsKinematic property from true (for scripted) to false (for PhysX)?

You’d think so, but no. In fact, the only way a rigidbody will cause a collision when moved with MovePosition is if the rigidbody is NON-kinematic. Makes no sense to me, but that’s the way it works.

I assumed I could get the collision info (relative velocity, normal), plug those values into Reflect, then take the result and assign that velocity to the rigidbody (VelocityChange). But the relative velocity values from the collision do not appear to be correct (only along one axis). It looks like the collision data are in local coordinates, but either way, the bounce is not correct.