Page 1 of 1

Problem with changing physics groups

Posted: Wed Jan 13, 2016 12:29 am
by kokkivos
I'm having a problem with switching physics groups quickly.

I'm working on a game where the point is to stay on a platform. By default, the Cylinder entity of a character has a CollisionGroup that collides with the boundary plane's StaticMesh, keeping him safe from falling if he runs towards the edge. He can only get hit off if another character's attack sends him flying, in which case the Cylinder's CollisionGroup is changed to a group that doesn't collide with the boundary.

The problem is that if a character is hit by an attack while his physics penetrate the boundary at all, the added velocity from the attack is negated and the character doesn't move. I'm assuming this is because I'm switching the player's physics group and then adding the velocity in the same frame, before the Space can update? Is there a way to fix that, or should I always wait a frame after changing the physics group to add the velocity?

Re: Problem with changing physics groups

Posted: Wed Jan 13, 2016 12:56 am
by Norbo
Changing the collision group should make it so that the next time step removes relevant collision constraints. Without constraints, nothing should stop the velocity change from having an effect.

If the group and velocity are modified from within an immediate event handler or some other stage which occurs during the execution of the engine, it will be too late to remove the constraints and the added velocity will be fought against. If this is the cause of the problem, then moving the group change and velocity change outside of the timestep execution will help.

Re: Problem with changing physics groups

Posted: Wed Jan 13, 2016 1:28 am
by kokkivos
Oh, right. I Forgot that my attack handler is called from an InitialCollisionDetected handler. I'll apply the changes from the character controller on the next frame instead. Thanks!