Jump to content
  • Advertisement
Sign in to follow this  
kirenemook12

Forward/Backward motion [Directx 10][C++]

This topic is 2482 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello

i want to make the movement in my game so that it moves forward, turns a bit, and moves forward, like a ship

this is my own attempt:


SpeedZ = 0.2;
SpeedX = tan(angle)*0.2;
if(fmod(RadToDeg(angle),360) < -90 || fmod( RadToDeg(angle),360) >90)
{
SpeedZ = -0.2;
SpeedX = tan(angle)*-0.2;
}
if (fmod(RadToDeg(angle),360) < -270 || fmod(RadToDeg(angle),360) >270)
{
SpeedZ = 0.2;
SpeedX = tan(angle)*0.2;
}




the problem with this is that when it moves along the X-axis, it goes too fast, and if it moves along the Z-axis it goes too slow

Share this post


Link to post
Share on other sites
Advertisement
Let me see if i understand. You want your object to have a set speed when it moves forward and turn at the same time?
Meaning that if given enough time it can go around in circles?

Share this post


Link to post
Share on other sites

Let me see if i understand. You want your object to have a set speed when it moves forward and turn at the same time?
Meaning that if given enough time it can go around in circles?


yes, it should always move in the same direction as its front

Share this post


Link to post
Share on other sites
always when I have no ideas i find the solution.
I had no idea, so this is the solution that i found, it is working perfect:



SpeedX = sin(angle)*Speed;
SpeedZ = cos(angle)*Speed;




thanks for all your time and effort

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!