Jump to content
  • Advertisement
Sign in to follow this  

Platformer Controls

This topic is 5232 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

Hi, I was just wondering if anyone can help me with the math behind platformer controls. I know how to program gamepads, but I seem to be having alot of trouble getting the usual character behaviour of a typical console game. I'm just trying to make it so when I push on a direction with the gamepad, the character will face that direction and then continue to walk/run in that direction while it's pressed. Can anybody shed some light on this for me? Thanks for any help.

Share this post

Link to post
Share on other sites
what you need to do is create a Mario64 style (tether) camera and have it follow your dude around.
Now on to the walking part. To get the direction the player should walk, you need to obtain the look vector and right vector of the camera. Then you can find out what way to orient your dude like this:

Vector2 dudeOrient;
Vector3 CameraLook = Already filled in by you;
Vector3 CameraRight = Already filled in by you;
Vector2 Input = you fill this in from the gamepad;

then you go like this :
dudeOrient.X = VectorLook * Input.X;
dudeOrient.Y = VectorRight * Input.Y;

now dudeOrient represents what way your guy should be looking/walking in world space. This means that if you push left, the guy will look/walk left relative to the camera.

The tether cam is pretty simple. You just make the camera always be a fixed distance from the target. If the camera becomes further that the distance you set, you move the camera straight towards your character. That is the basics of a classic Mario64 style controlling.

Excuse my syntax, I've been programming C# for too long.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!