Problem with Walk

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ansu832001
Posts: 95
Joined: Thu Mar 01, 2007 6:39 am

Problem with Walk

Post by ansu832001 »

Hi All,

i have some problem with Walk,

Th thing is my Walk() is working very well,but when i turn my camera Down and walk later camera is going into the earth rather moving forward/backward


Code for Forward/Backward :

public void Forward_Backward(float i) {
try {
Vector3D step = new Vector3D(0, 0, i);
Matrix4 matrix = new Matrix4();
direction = camera.Target - camera.Position;
double radius = camera.Target.DistanceFrom(camera.Position);
direction.Normalize();
matrix.RotateVect(ref direction);
cameraPos = camera.Position + (-1)*((diffMouseY)/2)*direction ;
SetPosition(cameraPos);
cameraTarget = camera.Position + (direction * (float)radius);
SetTarget(cameraTarget);
camera.UpdateAbsolutePosition();
}
catch (Exception ex) {
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
}


Code for TurnUp/Down:


public void Turn(int dir) {
try {

direction = camera.Target - camera.Position;
direction.Normalize();
double radius = camera.Target.DistanceFrom(camera.Position);
Matrix4 matrix = new Matrix4();
//Left Right
if (TURN.LEFT_RIGHT == dir)
matrix.RotationDegrees = new Vector3D(0, ((diffMouseX) / 120), 0);
//Up Down
if (TURN.DOWN_UP == dir)
matrix.RotationDegrees = new Vector3D(((diffMouseY)) / 50, 0, 0);

matrix.RotateVect(ref direction);
SetTarget(camera.Position + (direction * (float)radius));
camera.UpdateAbsolutePosition();

}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
}

Note: diffMouseY is used for speed .

My camera is walking forward/backward with no problem unless i turn my Camera Up/Down.When i turn Down and Walk camera is Going into the earth.

Help Needed.

Best Regards
Post Reply