About Store Forum Documentation Contact



Post Reply 
Character moving to the wrong direction
Author Message
Lancer Offline
Member

Post: #1
Character moving to the wrong direction
Hi,

so Im working on the movement function.

I have the following code to walk with W (to the front)

Code:
vHeading.x = Cos(m_pActor->angle.x);
vHeading.y = 0.f;
vHeading.z = Sin(m_pActor->angle.x);

float fDistanceToGo = 7.0f * Time.d();
Vec vDest(m_pActor->pos());
vDest += vHeading * fDistanceToGo;

but the character always moves to the right side instead of to the front.

I can fix this with
Code:
vHeading.x = Cos(m_pActor->angle.x + PI_2);
vHeading.y = 0.f;
vHeading.z = Sin(m_pActor->angle.x + PI_2);

but I don't think that is a proper solution.

The character is facing the "front" when viewing the model. (Same as in tutorial)
(This post was last modified: 07-26-2019 03:26 PM by Lancer.)
07-26-2019 12:23 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Character moving to the wrong direction
You can use that code, don't worry.
07-26-2019 03:28 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #3
RE: Character moving to the wrong direction
ye, if its an issue of the "facing" being wrong in orientation, you can change the orientation of the character, else you can modify it when movement is being done
07-26-2019 10:14 PM
Find all posts by this user Quote this message in a reply
Post Reply