Problem with updating model position via input
Hello everyone!
I have a problem, hopefully somebody can help me out with it.
Here is a sample of the code that is troublesome.
Vector3 inputModifier = new Vector3(
(keyboard.IsKeyDown(Keys.A) ? -1 : 0) + (keyboard.IsKeyDown(Keys.D) ? 1 : 0),
(keyboard.IsKeyDown(Keys.Q) ? -1 : 0) + (keyboard.IsKeyDown(Keys.E) ? 1 : 0),
(keyboard.IsKeyDown(Keys.W) ? -1 : 0) + (keyboard.IsKeyDown(Keys.S) ? 1 : 0)
);
player1.Position += new (inputModifier.X, yPosition.Y, inputModifier.Z);
Basically what I am trying to do is make it so that the X and Z coordinates are update via input, while the Y Coord is equal to that of the terrain, but im not sure how to update the position of the X and Z coordinates but not the Y.
Ive tryed doing something like..
player1.Position.X = inputModifier.X;
but for some reason it doesn't let me
Any help is appreciated, Thanks!
its obvious by your code that the keys Q and E are the ones modifying your hight.
try
try
Vector3 inputModifier = new Vector3((keyboard.IsKeyDown(Keys.A) ? -1 : 0) + (keyboard.IsKeyDown(Keys.D) ? 1 : 0), 0,(keyboard.IsKeyDown(Keys.W) ? -1 : 0) + (keyboard.IsKeyDown(Keys.S) ? 1 : 0));player.position += inputModifier;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement