I use joysticks and keyboards for testing. I recently had my player moving just fine. He would move forward and rotate with the left right stick like your standard 3rd person shooter or fps. But I could not strafe. So I looked at a tutorial on how to have complex movement with both the x and y axis. the code is:
Vector3 horizontalInput = new Vector3 (Input.GetAxis ("RotateH"), 0, Input.GetAxis ("RotateV"));
Debug.Log (Input.GetAxis ("RotateH"));
if (horizontalInput.magnitude > 1)
horizontalInput.Normalize ();
Vector3 targetHorizontalMovement = horizontalInput;
targetHorizontalMovement = cameraTransform.rotation * targetHorizontalMovement;
currentMovement = targetHorizontalMovement * moveSpeed;
but then my player wouldn’t move at all. So then I switched back to my already working code:
targetRotation += Input.GetAxisRaw ("Rotate") * rotationSpeed * Time.deltaTime;
if(targetRotation > 360)
targetRotation -= 360;
if (targetRotation < 0)
targetRotation += 360;
currentRotation = Mathf.SmoothDampAngle (currentRotation, targetRotation, ref rotationV, rotationSpeedSmooth);
//Rotation code.
transform.Rotate (0, Input.GetAxisRaw ("Rotate") * rotationSpeed * Time.deltaTime, 0);
//Smooth rotations.
transform.eulerAngles = new Vector3 (0,currentRotation ,0);
//Smooth player movements.
currentForwardSpeed = Mathf.SmoothDamp(currentForwardSpeed, Input.GetAxisRaw ("Vertical")* moveSpeed, ref forwardSpeedV, moveSpeedSmooth);
//Movement code.
currentMovement = new Vector3 (0, currentMovement.y, currentForwardSpeed);
//Proper movement.
currentMovement = transform.rotation * currentMovement;
But that wouldn’t work either. I did debug.log on the axis to see if it was responding properly and it was working fine. But the character won’t move. He will rotate but not move forward like he used to and I didn’t change any of the original code.