soulmate75

Hi all,
The http://creators.xna.com forums won't let me in, so I have to post this question here.

I have downloaded the SimpleAnimation demo from http://creators.xna.com and that compiled and ran without a hitch. I'm now extending the Tank class so that I can steer the tank around the screen.

I have a addition tank variable defined as...
Vector3 tankVelocity;

//Position of the model in world space, and rotation
Vector3 tankPosition;
float tankRotation;

My maths is not what it should be. So my question is, based on the tank's velocity and position how can I get it fairly realistically turn left and right using the steeringAngle variable I just want to be able to drive it around the screen.


Thanks.


Re: XNA Framework Realistic turning tank based on steering angle...

GMS0012

i have also a rotating tank... but 2d
i did it this way... (with vector2)
forward:

_Spieler.Aktiv.ScreenPos.X += (_Spieler.Aktiv.SpeedVor * (float)Math.Cos(((MathHelper.Pi / 2) - _Spieler.Aktiv.Drehwinkel)));

_Spieler.Aktiv.ScreenPos.Y += -(_Spieler.Aktiv.SpeedVor * (float)Math.Sin(((MathHelper.Pi / 2) - _Spieler.Aktiv.Drehwinkel)));

backward

_Spieler.Aktiv.ScreenPos.X += -(_Spieler.Aktiv.SpeedRuck * (float)Math.Cos(((MathHelper.Pi / 2) - _Spieler.Aktiv.Drehwinkel)));

_Spieler.Aktiv.ScreenPos.Y += +(_Spieler.Aktiv.SpeedRuck * (float)Math.Sin(((MathHelper.Pi / 2) - _Spieler.Aktiv.Drehwinkel)));

drehwinkel=rotation...





Re: XNA Framework Realistic turning tank based on steering angle...

soulmate75

Is your tank rotating, or is it turning I may be wrong, but the above code looks like the camera is rotating around your tank, rather than the tank producing a turning circle.




Re: XNA Framework Realistic turning tank based on steering angle...

Kyle_W

I would say the easiest way is probably to decide how many degrees per second you want the tank to turn and then on each update change the tank's direction by an appropriate number of degrees and then move the tank forward in the current direction an appropriate number of units.



Re: XNA Framework Realistic turning tank based on steering angle...

soulmate75

I believe the answer to this question can be found here...
https://creators.xna.com/forums/thread/1738.aspx
I have not tried it yet, but the thread has a flash demo that shows the logic in operation and basically does what I was talking about.