- Home /
Question by
Midane53 · Nov 27, 2016 at 02:56 PM ·
animatormecanimjumpingcharacter movement
Can't make my character to jump ??
Hey ! Got a little problem, all of my character's animations work, but only Jumping animation doesn't work. I'm working on mecanim. Here is a screen and the script, can you help me ? ^^
using UnityEngine;
using System.Collections;
[DisallowMultipleComponent]
[RequireComponent(typeof(Animator))]
public class Movement : MonoBehaviour {
Animator anim;
void Awake(){
anim = GetComponent<Animator> ();
}
void Update() {
/*Turning isn't necessary because the turning method is in the CameraTurning script,
*there's no movement within the character while turning. */
Strafe();
//Jumping
Jump();
//Walking
Walking();
//Moving
Move();
}
void Jump() {
if (Input.GetKey (KeyCode.Space)) {
anim.SetBool ("Jumping", true);
} else {
anim.SetBool ("Jumping", false);
}
}
void Walking() {
if (Input.GetKey (KeyCode.LeftShift)) {
anim.SetBool ("Walking", true);
} else {
anim.SetBool ("Walking", false);
}
}
void Move() {
anim.SetFloat ("Forward", Input.GetAxis("Vertical"));
}
void Strafe() {
//Right Strafe Run
if (Input.GetKey (KeyCode.E)) {
anim.SetBool ("RightStrafeRun", true);
} else {
anim.SetBool ("RightStrafeRun", false);
}
//Right Strafe Walk
if (Input.GetKey (KeyCode.E)) {
anim.SetBool ("RightStrafeWalk", true);
} else {
anim.SetBool ("RightStrafeWalk", false);
}
//Left Strafe Run
if (Input.GetKey (KeyCode.A)) {
anim.SetBool ("LeftStrafeRun", true);
} else {
anim.SetBool ("LeftStrafeRun", false);
}
//Left Strafe Walk
if (Input.GetKey (KeyCode.A)) {
anim.SetBool ("LeftStrafeWalk", true);
} else {
anim.SetBool ("LeftStrafeWalk", false);
}
}
}
ss2016-11-26at040522.jpg
(320.3 kB)
Comment
Your answer
Follow this Question
Related Questions
how to make 2d character jump? 0 Answers
Non-existent gameObjects appearing. 2 Answers
Is there a way to optimize animators? 3 Answers
Anima 2d 4 direction character 2 Answers
How to make character controller forward jump a certain distance? 1 Answer