Question by
ultimateronsu17 · Aug 21, 2015 at 09:40 PM ·
c#scriptingproblem
how would I add jump to my mecanim free form script
[code=CSharp]using UnityEngine; using System.Collections;
public class Movement : MonoBehaviour {
Animator anim;
bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
void FixedUpdate (){
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
anim.SetBool ("Ground", grounded);
}
// Update is called once per frame
void Update () {
float input_x = Input.GetAxisRaw ("Horizontal");
float input_z = Input.GetAxisRaw ("Vertical");
bool IsWalking = (Mathf.Abs (input_x) + Mathf.Abs (input_z)) >0;
anim.SetBool ("IsWalking", IsWalking);
if (IsWalking)
{
anim.SetFloat ("x", input_x);
anim.SetFloat ("z", input_z);
transform.position += new Vector3(input_x, 0f, input_z).normalized * Time.deltaTime;
if (grounded && Input.GetKeyDown (KeyCode.Space))
{
anim.SetBool ("Ground",false);
}
}
}
}[/code]
So where would I add my boolean in and how would it trigger it or is there better way of adding a junk to a free form direction mecanim controller because I've been on this for 4 days now
Comment
Your answer
Follow this Question
Related Questions
Function using seemingly impossible, unset values 2 Answers
How to rotate RigidBodyFPSController (C#) 1 Answer
Microphone Input to Spawn object 2 Answers
enable/disbale particle system in 5.3.2 1 Answer
Try part of C# not being Read 1 Answer