In our ping pong game, we have a paddle, table, and ball physics entites.
We are having a problem with the ball going through our paddle. Sometimes the ball hits the paddle, and sometimes the ball goes through. We have increased the chance of it hitting by making the paddle wider, but we would rather not do that.
Have you ever encountered this before?
What could be the a solution?
Richard
Entity moving through our other entities
Re: Entity moving through our other entities
When using discrete collision detection, it's possible for an object to have sufficient velocity to 'tunnel' through another object. This is because the width of the objects is less than the per-frame movement of the objects.
If that is the source of your problem, then setting the relevant entities' PositionUpdateMode to Continuous will fix the issue (or just set MotionSettings.DefaultPositionUpdateMode to Continuous before you create entities if you want all entities to have it).
However, if your objects' velocities do not match their motion and instead teleport (setting Position or Orientation, for example), continuous collision detection won't be able to help. In addition, even if the collision is caught, the incorrect velocities will cause collision response to fail.
If that's the problem, then you need to control the motion of your entities using forces of velocities rather than teleportation. The EntityMover and EntityRotator helper classes can make this easier; they target a goal state and work towards it. For dynamic entities, a SingleEntityLinear/Angular motor is used; for kinematic entities, the velocity is adjusted such that the goal will be hit in the next frame.
If that is the source of your problem, then setting the relevant entities' PositionUpdateMode to Continuous will fix the issue (or just set MotionSettings.DefaultPositionUpdateMode to Continuous before you create entities if you want all entities to have it).
However, if your objects' velocities do not match their motion and instead teleport (setting Position or Orientation, for example), continuous collision detection won't be able to help. In addition, even if the collision is caught, the incorrect velocities will cause collision response to fail.
If that's the problem, then you need to control the motion of your entities using forces of velocities rather than teleportation. The EntityMover and EntityRotator helper classes can make this easier; they target a goal state and work towards it. For dynamic entities, a SingleEntityLinear/Angular motor is used; for kinematic entities, the velocity is adjusted such that the goal will be hit in the next frame.