I am trying to make my player move with its animation i made. I made a script to allow it to move with WASD and Arrow keys and i made a separate script for the animations.
Moving Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public float moveSpeed;
void Start ()
{
moveSpeed = 6f;
}
void Update ()
{
//Trigger Movement
transform.Translate(moveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis ("Vertical") * Time.deltaTime);
}
}
}
Animation Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Animations : MonoBehaviour {
public Animator anim;
public KeyCode MoveW;
public KeyCode MoveA;
public KeyCode MoveS;
public KeyCode MoveD;
void Start () {
}
void Update () {
//Trigger Move Animation
if (Input.GetKeyDown(MoveW))
{
anim.SetTrigger("MoveTrigger");
}
}
}