I have two objects, that both need to move to physics realistically. Object ‘A’ needs to bounce off object ‘B’, without object ‘B’ having their physics changed.
I’ve tried stopping the velocity change in OnCollisionEnter(), but it looks like that’s called after the physics update on the collision itself and there’s no reference to the change in physics OnCollisionEnter().
It looks like my only option is to set object ‘B’ as kinematic and create the physics myself. I’ve had a look around google for a few hours, but can’t find any clean explanation on how to create physics movement.
Also how would you handle ‘jumping’, as jumping is normally not an instantaneous ‘up’. Those forces are normally handled over a (minuscule) amount of time.
I’ve not used much physics with unity, but in reality, if you bounce a ball off the ground, the ground doesn’t move because of its enormous mass. (or it moves so slightly it’s inconceivable). So maybe set object B’s mass to be a huge number?
As for jump, looking at the docs, rigidbody.AddForce should do the trick
I think the correct setup would be to set object B as kinematic and leave physics on for object A. Object A should still bounce off B, without B doing anything.
May have misread but I think that OP was trying to make Object B still act to physics but not react to collisions with Object A.
Have you tried setting a boolean on Object B when the collision with Object A has been registered, and then in the physics update checking for that boolean and negating any acceleration. If you wanted it to be perfect cancellation you could calculat the forces that were exerted onto Object B and remove them from the current forces that move it.