Problem with changing physics groups

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
kokkivos
Posts: 19
Joined: Sat Apr 13, 2013 6:18 pm

Problem with changing physics groups

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Problem with changing physics groups

Post 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.
kokkivos
Posts: 19
Joined: Sat Apr 13, 2013 6:18 pm

Re: Problem with changing physics groups

Post 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!
Post Reply