# Reversed Controls?

 0 im working on a 2d platformer and when a attach my movement script the controls are reversed left left arrow goes right and the right arrow goes left! my script: var playerSpeed : int; function Update () { // amount to move player amtToMove = (playerSpeed*Input.GetAxis("Horizontal")) *Time.deltaTime; //move/translate the player transform.Translate(Vector3.right*amtToMove); } more ▼ asked Aug 19 '10 at 05:02 PM john 2 75 ● 29 ● 35 ● 46 is playerSpeed positive? Aug 19 '10 at 05:06 PM skovacs1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 Either you are negating the axis or your camera is looking down the wrong end of the Z axis for that code to work as you expect. Rotate everything in your scene by 180 degrees to fix the problem. An easy way to do this is to add an empty gameObject, drop everything onto it. Rotate by 180 degrees, then drag them off and delete it. Alternatively you could do something like using mainCamera.transform.right or one of the player axes like transform.forward (as appropriate) in stead of the global Vector3.right. more ▼ answered Aug 19 '10 at 05:16 PM skovacs1 10k ● 11 ● 25 ● 92 Thanks i guess this question just involved "common sense"! Aug 19 '10 at 05:34 PM john 2 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 Vector3.right is always (1/0/0), you want to use the right-Vector of your current transform instead: ``````transform.Translate(transform.right*amtToMove); `````` Since you said this is a 2D-game, and you are certain the camera orientation/the player never rotates (so "right" is always the same "right), then you can keep your version, and simply add a sign: ``````transform.Translate(Vector3.right*(-amtToMove)); `````` more ▼ answered Aug 19 '10 at 06:00 PM Wolfram 9.1k ● 8 ● 20 ● 53 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x5273
x1071
x230

asked: Aug 19 '10 at 05:02 PM

Seen: 1050 times

Last Updated: Aug 19 '10 at 05:02 PM