Thanks to everyone that’s helped me with learning how to use mecanim. My character can move in the direction I want (and the walk/Idle transitions are smooth). But I want to be able to use a run animation and a jump animation.
My questions are:
- Is it possible to set “shift” as a parameter so that when it’s pressed my character will start running? Will shift be a bool or trigger?
- Is it possible to set “spacebar” as a parameter so that when it’s press the character will jump? Will it be a bool or trigger?
As you can tell I’m not that good at C# coding (as you already know coding is the largest obstacle for new unity users). And I was wondering can I code certain triggers into mecanim as a parameter so that I don’t have to code it in C# (or javascript).
Thank you for your time.
P.S.
Below is my C#code I learned from a tutorial to make my character move. How would I modify it (or would I have to) if I set the parameters within mecanim?
using UnityEngine;
using System.Collections;
public class IdleWalk : MonoBehaviour
{
Animator animator;
public float DirectionDampTime = 0.25f;
// Use this for initialization
void Start ()
{
animator = GetComponent<Animator> ();
}
// Update is called once per frame
void Update ()
{
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
animator.SetFloat ("Speed", h*h + v*v);
animator.SetFloat ("Direction", h, DirectionDampTime, Time.deltaTime);
}
}