Rotate to position of right thumbstick

Nov 24, 2012 at 2:44 AM
Edited Nov 24, 2012 at 2:46 AM

I'm trying to make two bodies rotate to the same angle as the player pushes the right thumbstick.

ship.Rotation = (float)System.Math.Atan2(input.GamePadState.ThumbSticks.Right.X, input.GamePadState.ThumbSticks.Right.Y);

Which works PERFECTLY.

HOWEVER why I try to add in the shield which I currently link to the ship via a distance and angular joint.  And apply the (float)System.Math.Atan2(input.GamePadState.ThumbSticks.Right.X, input.GamePadState.ThumbSticks.Right.Y); to just the ships rotation then the ship is fine but the shield rotates very slowy. 

If I apply the rotation to just the shield the shield is find but the ship bounces around alot.

if I apply the rotation to both the ship and shield they are both fine EXCEPT they BOTH boune around ALOT.  I'm not sure how to fix this.

Any suggestions would be creatly appreciated. 

 

More info

Both the ship and shield are compound polys read in from the textures. 

collision is turned off between the ship and sheild.

joint info

const float dampingRatio = 1f;
            const float frequency = 25f;
            JointFactory.CreateAngleJoint(World, ship, shield);
            DistanceJoint ShieldLink = new DistanceJoint(ship, shield, new Vector2(0f, 0f), new Vector2(0f, (2*GameSettings.Default.Scale)));
            
            ShieldLink.CollideConnected = false;
            ShieldLink.DampingRatio = dampingRatio;
            ShieldLink.Frequency = frequency;
            ShieldLink.Length = 0;


I would love to do this with applylinear impulse but that just seemed to make them into pendulem. 

Again i want to have the ship faceing one way. the player pushed up and right on the thumbstick then the ship and shield both face up and right with no bouncing.

Thanks

 

Edit:

I also tried just using one body and attaching both as fixtures but i cant seem to use any offset since both are compound and they end up just ploping one on top of the other.  Plus this may have issues later when I want to make it so collision passes though the shield when it doesnt have power and hits the ship.

Nov 24, 2012 at 11:13 AM
Edited Nov 24, 2012 at 11:15 AM

Some things you can try:

- Make the joints more rigid (e.g. Frequency=0 for the DistanceJoint, for the AngleJoint I suppose the softness parameter).

- Use a PrismaticJoint with limits instead of distance+angular. It's quite rigid on its own.

- Make the shield lighter (lower density) so it responds more easily to the forces on the ship

- Low level solution - don't use joints. In each Update() set manually position and rotation of the shield according to the ship transform. This might lead to collision problems if you need shield collisions due to unphysically teleporting the shield but might be ok in your scenario.

If you need collision to pass through the shield when it's low power just set its collision category dynamically or make a collision callback on contact and return false to ignore the collisions.