Monday, January 18, 2016

c++ - I am looking to create realistic car movement using vectors


I have goggled how to do this and found this http://www.helixsoft.nl/articles/circle/sincos.htm I have had a go at it but most of the functions that were showed didn't work I just got errors because they didn't exist. I have looked at the cos and sin functions but don't understand how to use them or how to get the car movement working correctly using vectors. I have no code because I am not sure what to do sorry.


Any help is appreciated.


EDIT:


I have restrictions that I must use the TL engine for my game, I am not allowed to add any sort of physics engine. It must be programmed in c++. Here is a sample of what i got from trying to follow what was done in the link I provided.


if(myEngine->KeyHeld(Key_W))
{

length += carSpeedIncrement;
}
if(myEngine->KeyHeld(Key_S))
{
length -= carSpeedIncrement;
}
if(myEngine->KeyHeld(Key_A))
{
angle -= carSpeedIncrement;
}

if(myEngine->KeyHeld(Key_D))
{
angle += carSpeedIncrement;
}

carVolocityX = cos(angle);
carVolocityZ = cos(angle);

car->MoveX(carVolocityX * frameTime);
car->MoveZ(carVolocityZ * frameTime);



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...