- Home /
Character is moving forward and backward on it's own
So im just starting using unity and trying the free asset robot kyle since kyle have no animation i have to find another character with walking and i found one. I already have animation component and animator just to be sure, i don't know about the code if it is right or their are still missing to make kyle move by keyboard control. i already check the setting for input and it's good and also their is no problem with the vjoy stick in my laptop. i have no idea what make kyle or my character move on it's own.
private string moveInputAxis = "Vertical";
private string turnInputAxis = "Horizontal";
public float rotationRate = 360;
public float moveSpeed = 2;
void Start()
{
}
// Update is called once per frame
void Update()
{
float moveAxis = Input.GetAxis(moveInputAxis);
float turnAxis = Input.GetAxis(turnInputAxis);
ApplyInput(moveAxis, turnAxis);
}
private void ApplyInput(float moveInput,
float turnInput)
{
Move(moveInput);
Turn(turnInput);
}
private void Move(float input)
{
transform.Translate(Vector3.forward * input * moveSpeed);
}
private void Turn(float input)
{
transform.Rotate(0, input * rotationRate * Time.deltaTime, 0);
}
}
Have you tried logging to the console the values you get from the Input.GetAxis methods?
If they are zero then somthing outaide of the script is affecting the character.
Check if settings have a large enough dead zone.
Answer by Harrison_Strange · Aug 10, 2020 at 03:53 AM
@tris20 Hey, I'm having the same problem. Did you figure out what was wrong?
Your answer
![](https://koobas.hobune.stream/wayback/20220612185557im_/https://answers.unity.com/themes/thub/images/avi.jpg)