I have checked and rechecked the code and even re wrote the code a different way. i have restarted the program and system but for some reason i can make the player look up/down/left/right and animate this but it will not move? please help its driving me nuts.
Unity shows no errors btw.
My movement script:
using UnityEngine;
using System.Collections;
public class Playermove : MonoBehaviour {
public float speed = 1;
private Animator animator;
// Use this for initialization
void Start () {
{
animator = this.GetComponent<Animator> ();
}
}
// Update is called once per frame
void Update()
{
var vertical = Input.GetAxis("Vertical");
var horizontal = Input.GetAxis("Horizontal");
if (horizontal > 0)
{
transform.Translate(Vector2.right * speed * Time.deltaTime);
animator.SetInteger("Direction", 2);
}
else if (horizontal < 0)
{
transform.Translate(-Vector2.right * speed * Time.deltaTime);
animator.SetInteger("Direction", 0);
}
else if (vertical > 0)
{
transform.Translate(Vector2.up * speed * Time.deltaTime);
animator.SetInteger("Direction", 1);
}
else if (vertical < 0)
{
transform.Translate(-Vector2.up * speed * Time.deltaTime);
animator.SetInteger("Direction", 3);
}
else if (horizontal == 0)
{
animator.SetInteger("Direction", 4);
}
}
}