- Home /
Controls reversed with w and s?
I'm pretty sure the camera is on the wrong side but I cant tell so I came here.
Right now I'm making a 3D platformer and when i use the controls they are reversed I have no clue why and i have been trying to figure it out.
This is my code for the camera right now :
using UnityEngine;
public class CameraFollow : MonoBehaviour{
public Transform target;
public float smoothSpeed = 0.125f;
public Vector3 offset;
public float rotateSpeed;
public Transform pivot;
void Start () { pivot.transform.position = target.transform.position;
pivot.transform.parent = target.transform;
Cursor.lockState = CursorLockMode.Locked;
}
void LateUpdate () {
float horizontal = Input.GetAxis("Mouse X") * rotateSpeed;
target.Rotate(0, horizontal, 0);
float vertical = Input.GetAxis("Mouse Y") * rotateSpeed;
pivot.Rotate(-vertical, 0, 0);
float desiredYAngle = target.eulerAngles.y;
float desiredXAngle = pivot.eulerAngles.x;
Quaternion rotation = Quaternion.Euler(desiredXAngle, desiredYAngle, 0);
transform.position = target.position - (rotation * offset);
//Vector3 desiredPosition = target.position + offset;
//transform.position = desiredPosition;
transform.LookAt(target);
}
}
Comment