getting a charachter to always face the direction they are traveling

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
ok. i have gotten some answers to this on other boards but its all in c++ and older directX ( Not directX9 & c#, which is all i know).my problem is i have a charachter. at the moment he is in a room. when he hits a wall ( or before) he is going to turn to avoid the colission. the problem is keeping the charachter always facing the direction that he/she is travelling. i am viewing the scene from a fixed position over head. the only things i have to work with is my current position, my last position and the fact that the charachter can not move along the y axis ( i am not giving the ability to jump).can anyone help with this, in as simple a way as possible, using directX 9 ( and hopefully c#)? thanks all
 
Hey,

All you have to do is simply rotate the character.


d3ddev.transform.world = MapMatrix
RenderMap()

d3ddev.transfrom.world = matrix.rotation(Matrix.Multiply(characterPosition, characterRotation))
RenderCharacter

The characterRotation matrix wuold be some Matrix.RotationYawPitchandRoll matrix and the characterPosition would be some Matrix.Translation matrix.

I'm not 100% sure if it's:
Matrix.Multiply(characterPosition, characterRotation) or
Matrix.Multiply(characterRotation, characterPosition)

I'm assuming, since you said that the camera is always fixed that your view matrix is a matrix.lookatLH or RH with a constant camreaPosition CamreaTarget and cameraTarget.

-The Pentium Guy
 
Back
Top