So basically I’m trying to get my character to move, I’ve set up the animation to change the character from idle to walk in Animation. Ive now made a script that is supposed to move it, but the public float is not showing up in the inspector. Hers the code:
using UnityEngine;
using System.Collections;
public class Pixelani : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;
void Start () {
anim = GetComponent <Animator> ();
}
// Update is called once per frame
void FixedUpdate () {
float move = Input.GetAxis ("Horizontal");
anim.SetFloat ("Speed", Mathf.Abs (move));
rigidbody2D.velocity = new Vector2 (move * maxSpeed, Rigidbody2D.velocity.y);
if (move > 0 && ! facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Flip()
{
facingRight =! facingRight;
Vector3 theScale = transform.localscale;
theScale.x *= -1;
Transform.localscale = theScale;
}
}
Any help at all will be appreciated. Thanks.