The body does not rotate face down with gravity

I have a rectangular body that shoots from the canon at an angle of 45 degrees. The body also rotates at an angle of 45 degrees, and I set the mass in front of the body.

The body rises in the air, however, when the body returns to the ground, it does not rotate. Is there a way for the side of the mass to drop first?

My real world example is throwing a tennis ball with a string attached to the air. Currently, the line does not lag behind the ball when gravity comes into effect.

Here is my ball

Body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(texture.Width), ConvertUnits.ToSimUnits(texture.Height),100f, postition, this); Body.Mass = 1; Body.LocalCenter = new Vector2(ConvertUnits.ToSimUnits(Texture.Width), ConvertUnits.ToSimUnits(Texture.Height / 2)); Body.UserData = this; Body.BodyType = BodyType.Dynamic; Body.CollisionCategories = Category.All; Body.CollidesWith = Category.All; Body.IgnoreGravity = false; float ang = BarrelJoint.JointAngle; Body.Rotation = ang; 

Then I do this to run it:

 Body.ApplyLinearImpulse(new Vector2((float)Math.Cos(ang) * 100, (float)Math.Sin(ang) * 100)); 

I assume that there are some settings or calculations that I forget.

+7
source share
1 answer

For those who will read this in the future, I have nevertheless developed.

I realized that the speed would change the way I would like the rotation to change. Thus, I based the rotation on speed, the more gravity decreases, the more the object turns face down.

In my object update class, I add the following (note: potentially bad math)

 public override void Update(GameTime gameTime) { Vector2 velocity = Body.LinearVelocity; float radians = (float)(Math.Atan2(-velocity.X, velocity.Y) + Math.PI/2.0); Body.Rotation = radians; base.Update(gameTime); } 

And ta da we have a rotating object.

+1
source

All Articles