Hi! New here in the community.
I have this really simple controls in my FbX character. I want to add in it a simple animation called “walk” when i press the button.
transform.Translate(Vector3.right * Input.GetAxis(“Horizontal”) * playerSpeed * Time.deltaTime);
So, i have animations called “idle” and “walk” and i want my character to use walk animation when i use this Input.GetAxis command.
Thanks!
This is my code:
using UnityEngine;
using System.Collections;
public class player : MonoBehaviour {
public float playerSpeed = 5.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.right * Input.GetAxis ("Horizontal") * playerSpeed * Time.deltaTime);
if(Input.GetAxis("Horizontal"))
animation.Play("walk");
else if(Input.GetAxis("idle"))
animation.Stop();
}
}
And Unity complains " error CS0029: Cannot implicitly convert type “float” to “bool” ?