Jump to content
Xtreme .Net Talk

getting a charachter to always face the direction they are traveling


Recommended Posts

Posted
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
Posted

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

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...