My character is not only moving to X upon my instruction, it is moving to Y and Z as well, following is my code, appreciate somebody could advise.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player1move : MonoBehaviour
{
private Animator Anim;
[SerializeField] public float WalkSpeed = 0.01f;
// Start is called before the first frame update
void Start()
{
Anim = GetComponentInChildren<Animator>();
}
// Update is called once per frame
void Update()
{
// Walking left and right
if(Input.GetAxis("Horizontal") > 0)
{
Anim.SetBool("forward", true);
transform.Translate(WalkSpeed, 0,0);
}
if (Input.GetAxis("Horizontal") < 0)
{
Anim.SetBool("backward", true);
transform.Translate(-WalkSpeed, 0, 0);
}
if (Input.GetAxis("Horizontal") == 0)
{
Anim.SetBool("forward", false);
Anim.SetBool("backward", false);
}
// Jumping and bending
if (Input.GetAxis("Vertical") > 0)
{
Anim.SetTrigger("jump");
}
if (Input.GetAxis("Vertical") < 0)
{
Anim.SetBool("bend", true);
}
if (Input.GetAxis("Vertical") == 0)
{
Anim.SetBool("bend", false);
}
}
}