Hello guys, i have a problem with my parameter. Why doesn't my "speed" parameter work for my idle and run? Perhaps i lack something with my codes? Here's my code: using UnityEngine; using System.Collections; public class characterMove : MonoBehaviour { private float playerSpeed = 5.0f; public GameObject target; public bool jump = false; public float jumpForce = 10f; private Transform groundCheck; private bool grounded = false; void Awake() { groundCheck = target.transform.Find("groundCheck"); } // Use this for initialization void Start () { } // Update is called once per frame void Update () { grounded = Physics2D.Linecast(target.transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("ground")); }//update void FixedUpdate () { if(jump){ target.rigidbody2D.AddForce(new Vector2(0f,250f)); jump = false; } } void OnGUI () { if(GUI.RepeatButton(new Rect(0,0,Screen.width,Screen.height/2),"Jump") grounded) { jump = true; } if(GUI.RepeatButton(new Rect(0,Screen.height/2,Screen.width/2,Screen.height/2),"L")) { target.transform.Translate(Vector2.right * playerSpeed * Time.deltaTime); target.transform.rotation = Quaternion.AngleAxis(180, Vector3.up); } if(GUI.RepeatButton(new Rect(Screen.width/2,Screen.height/2,Screen.width/2,Screen.height/2),"R")) { target.transform.Translate(Vector2.right * playerSpeed * Time.deltaTime); target.transform.rotation = Quaternion.AngleAxis(0, Vector3.up); } }//GUI } //class
Yeah, I don't see anything in your code that actually sets the speed. I would expect to see something like: Code (csharp): animator.SetFloat("speed", Input.GetAxis("Horizontal")) or whatever other speed you want to set. HTH, - Joe