Game Programming Help

I am working on a game project and need some help with programming. How do I get objects to collide and bounce off of other objects without ever stopping or slowing down?

This is a somewhat vague post but I’ll try to help out.

First thing, you’ll probably want your objects to be simulating Physics. If you want them to bounce and spin without any drag force whatsoever, then I would suggest setting LinearDamping and AngularDamping to zero on the physics-simulating object (probably a collision sphere or a mesh right?). This does mean that they will literally never stop moving.

You can easily setup a delegate (or an event in blueprints) that will call a function when your object hits something. I believe it’s something like this (but I know that the parameters for the function are wrong so this will give you a compiler error, check the docs to see what the correct parameters are for a Hit event).

Constructor



          Collision->OnComponentHit.AddDynamic(this, &AMyActor::OnImpact);


Function



          void AMyActor::OnImpact(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)


You can then use the ‘Impulse’ from the hit to add a force to the objects, causing them to bounce off of each other. The physics engine normally does this anyway, so you might not even have to set that up.