Jump to content
  • Advertisement
Sign in to follow this  
Tutorial Doctor

Controls Programming/Mapping?

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

Okay, so I have a 3rd person scene setup that makes the character move, but I have a very poor control system, and mainly because I am using a PC with no game controller (I could use a script that maps things to a joystick, but I want it to feel good using a keyboard). 


So, right now I have an empty for the body of the player, and an empty for the head of the player. Then I have a camera parented to the head object, and I script the head object to control like any 1st person game would on a PC. The mouse controls the direction you look in. 


Then I parent the actually 3d model of the character to the player empty. When I rotate however, it looks like the 3d model is glued to the camera. haha. 


Metal Gear Solid Controls are ideal (at least how intuitive they feel), but how would I do this on a PC?


I think controls can make or break a game, because that is what we are giving the user the ability to do-- control the game we design. 


Anyone have any ideas? Or perhaps can suggest some PC games that "do it right?"


Edit: Okay, for one style of game, the control scheme I have set up might work, but I would still like tips on how to do it like Metal Gear. I sort of have it though. 


Current Scheme: Camera both follows and looks at 3d character model. Dragging left on mousepad rotates the character to the left, and the opposite for the right. Move forward using the "W" key. Another control would rotate the camera around the character. TBC...

Edited by Tutorial Doctor

Share this post

Link to post
Share on other sites

I'm not sure what part(s) you need help with. It sounds to me that you have an offset problem. For 3rd person views (over-the-shoulder), your character's position is a pivot point on a fixed camera with an offset. So, all movement and physics are centered around the player-character and the camera is at a certain offset (rotated by the rotation matrix) from that player-character...... Does this help? As I said, I'm not sure what you want.....

Share this post

Link to post
Share on other sites
Thanks Hawkblood. My brother fired up Metal Gear Solid, and demonstrated it for me. You are right, the character is the pivot point.

I guess I am wondering how I should map the keys to make the controls fluid. At first, swiping right on the mousepad rotated the character to the right, and swiping left rotated the character to the left. I actually like how that feels too, and I might use it over the Metal Gear Solid control scheme.

I might use one or the other depending on the style of game I choose to make. Thanks again for responding!

Share this post

Link to post
Share on other sites

Always have options to change the directionality of the mouse axis' to accommodate different players' preferences. The same goes with keyboard bindings.

Share this post

Link to post
Share on other sites

I see a lot of games today that don't let you change your controls. I will definitely try to implement that!

Which is most definitely wrong. If there's one thing you convey to other people making games please make it be that they should not follow suit in the same laziness that a lot of AAA developers show these days, especially in PC ports. Controls and options are one thing that it is almost always better to have more of, short of it being haphazard.


In particular right now so many companies have focused all their efforts on developing games for console to where it is rare for us to even get basic features like key rebinding on ports, i f they do feature that, there is usually a lot of other stuff broken.


So yes, please do!

Share this post

Link to post
Share on other sites
You're describing problems in two different areas: one is related to your game camera and the other is related to the player controls.


So, right now I have an empty for the body of the player, and an empty for the head of the player. Then I have a camera parented to the head object


When I rotate however, it looks like the 3d model is glued to the camera.

This behaviour is a direct consequence of parenting the camera to something controlled by the player.

The camera shouldn't be parented to the player character or one of its children. Instead, it should be controlled by a solver that tracks the player.
A possible definition for a solver is "a software routine that aims to solve a problem given a set of constraints."
Your "3rd person camera solver," a routine\method\function that you call each game tick to reposition and reorient your camera, could have the following constraints:
  • If the player is standing still, centre the player character on screen.
  • If the player is moving, centre on screen the point between the player character and a point ahead of the player in the direction that he's heading*.
  • Prevent level geometry from occluding the player.
  • Always mantain a certain distance from the player.
  • Always use Ease-In and Ease-Out interpolation when transforming the camera
* This is a feature that is often overlooked in independent\smaller projects, but can be consistently seen in AAA games. It allows you to see "ahead" and anticipate obstacles. The player character is still on screen, but his focus is shared with an arbitrary point ahead of him in the direction that he's heading.
You do this by making the camera aim at exactly the average position between the player character and this point ahead of him. You interpolate between the player position in a manner such that when the player is not moving, the camera is solely focusing on him. The faster that the player moves, the more you focus on the average position between the player character and the arbirtrary point.
I have implemented this in a small demo that you can download here: http://www.gamedev.net/topic/650327-why-do-2d-games-have-main-character-locked-in-the-middle-of-the-screen/#entry5111055

I believe that by far what makes the most difference with controls is regarding the player input for movement as relative to the camera.
When you press the "move to the right" key, you transform the [1, 0, 0] 3D vector from the local space of the camera to the world space, and then proceed to move and orient the player character with the resulting world space vector.
A lot of games (especially console games) don't make use of "turn left" or "turn right" keys. Rather, there are only movement keys and when you move the player character, he turns to face the direction that you are moving him with.
In some games you can even steer the player character just by having him move forward and then orbiting the camera around him - this is evidence that the movement is relative to the camera.
This style of control is much more intuitive. Regardless of where your character may be facing, pressing "right" will make him turn to the right side of the camera (for the person playing, it's the "right side of the screen") and move in that direction.
I'm not sure if you're using Unity. This is demonstrated in their documentation for the "transform.TransformDirection()" method:
http://docs.unity3d.com/Documentation/ScriptReference/Transform.TransformDirection.html Edited by Kryzon

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!