So, I got this to do the anims for my sprite in Unity 2d...
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public float Speed = 2;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
}
void FixedUpdate () {
rigidbody2D.velocity = new Vector2(Input.GetAxis("Horizontal") * Speed, 0);
anim.SetFloat("HorizontalSpeed", Mathf.Abs(rigidbody2D.velocity.x));
if(transform.localScale.x > 0 && rigidbody2D.velocity.x < 0)
transform.localScale = new Vector3(-1, 1, 1);
if(transform.localScale.x < 0 && rigidbody2D.velocity.x > 0)
transform.localScale = new Vector3(1, 1, 1);
}
}
That works fine... then I add the script so he can move up and down. (the previous was moving left+right)
using UnityEngine;
using System.Collections;
public class UpMove : MonoBehaviour {
public float VerticalSpeed = 2;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
}
void FixedUpdate () {
rigidbody2D.velocity = new Vector2(Input.GetAxis("Vertical") * VerticalSpeed, 0);
anim.SetFloat("VerticalSpeed", Mathf.Abs(rigidbody2D.velocity.y));
}
}
Welll.. The second script doesn't do anything. I've been working at this (rookie noobness) for around an hour now.. so pls pls pls.