Jump to content
  • Advertisement
Sign in to follow this  
joejoeself

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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;


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!