- Home /
My input manager doesn't always respond to my code
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.
Answer by jdelaay025 · Jul 29, 2015 at 12:28 AM
I actually figured it out after a few minutes. I never called the controller to actually make any actions thus there was no movement. All I did was add
controller.Move(currentMovement * Time.deltaTime);
and the character moves exactly how it is supposed to.
Answer by jdelaay025 · Jul 29, 2015 at 12:28 AM
This is so cool that I asked this question so little time ago and it's already being responded to by people. I love the unity community. yes. the input was in the update section
Your answer
![](https://koobas.hobune.stream/wayback/20220611233506im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
how to set up a joystick using input manager for first person controller in unity 4.2.1? 1 Answer
Joystick Input - "3rd Axis" etc, not sure what works/doesn't 1 Answer
Joystick & RotateAround 1 Answer
I cant figure out how to change my simple Movement controls to touch, can anyone help? 1 Answer