Hey
so ive been working on my custom 2d top down movement,
my problem is that the moving animation only works on the y axis.
using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour {
PlayerShoot PlayerShoot;
private Animator anim;
AudioSource audio;
public int health = 40;
public float movespeed = 4.0f;
bool facingRight = true;
public AudioClip KickSound;
void Start ()
{
audio = GetComponent<AudioSource>();
anim = GetComponent<Animator>();
}
void FixedUpdate () {
float x = Input.GetAxis("Horizontal");
float y = Input.GetAxis("Vertical");
anim.SetFloat("move", Mathf.Abs(x));
GetComponent<Rigidbody2D>().velocity = new Vector3(x * movespeed, y * movespeed, GetComponent<Rigidbody2D>().velocity.y);
anim.SetFloat("move", Mathf.Abs(y));
if (x > 0 && !facingRight)
Flip();
else if (x < 0 && facingRight)
Flip();
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}