# Problem with updating model position via input

This topic is 3499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

##### Share on other sites
Anybody have any suggestions?

##### Share on other sites
its obvious by your code that the keys Q and E are the ones modifying your hight.

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;

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633330
• Total Posts
3011388
• ### Who's Online (See full list)

There are no registered users currently online

×