I'm having trouble wrapping my head around something that should be relatively simple. I'm making a breakout clone using LibGDX and Box2D. I'm also using the Ashley ECS. For movement with bodies, I have two components - a BodyComponent (BC) which contains a reference to the Body that was created for the owning entity, and a PhysicsComponent (PC) which contains a velocity vector.
What I'm currently doing is manipulating the PC's velocity vector when providing input, then setting the BC's body's linear velocity to the velocity vector in the PC. This allows my bodies to move how I want them to move but there are two issues:
- Bodies have no maximum velocity
- If the pad bumps into a static body, it should bounce. However it quickly snaps back to its original position because the PC's velocity is unaffected when bodies collides.
How can I manipulate bodies and make them move and interact with other bodies without the need to use another component for velocity?