I've recently been getting my teeth stuck into Box2D and have been greatly enjoying the experience so far.
I've been recently working on a project in which player can control a body. The body that he player controls is meant to move around another body at the center of the screen. If the player presses left or right the outer body will move in a circular fashion around the object in the center. If the player moves up or down then the outer body will move closer or further away from the center. The player can also move in a combination of the both the left/right and up/down. The inner body will also always be stationary.
I was hoping to get a few suggestions about the best way to do this in Box2D.
Currently I have two schools of thought.
The first is to apply a force when the player requests to move the outer body. This force will be along a tangent to the circular path that it can take. After this force is applied I'd then apply a force each time I step to make it move in a circular motion. (F=mv^2/r) where F is applied towards the center of the circle.
The second is to use joins. I'd have a distance joint between the center body and the outer body. Then when requested to move left the inner body would rotate on the spot. The problem with this approach is when I want to move outwards I can't because the only suitable join seems to be a fixed distance joint.
I'm looking for an approach that would be efficient to implement. Unfortunately my Physics skills are a bit rusty.
Any help or suggestions would be greatly appreciated.
I've been recently working on a project in which player can control a body. The body that he player controls is meant to move around another body at the center of the screen. If the player presses left or right the outer body will move in a circular fashion around the object in the center. If the player moves up or down then the outer body will move closer or further away from the center. The player can also move in a combination of the both the left/right and up/down. The inner body will also always be stationary.
I was hoping to get a few suggestions about the best way to do this in Box2D.
Currently I have two schools of thought.
The first is to apply a force when the player requests to move the outer body. This force will be along a tangent to the circular path that it can take. After this force is applied I'd then apply a force each time I step to make it move in a circular motion. (F=mv^2/r) where F is applied towards the center of the circle.
The second is to use joins. I'd have a distance joint between the center body and the outer body. Then when requested to move left the inner body would rotate on the spot. The problem with this approach is when I want to move outwards I can't because the only suitable join seems to be a fixed distance joint.
I'm looking for an approach that would be efficient to implement. Unfortunately my Physics skills are a bit rusty.
Any help or suggestions would be greatly appreciated.