- Home /
Help ThirdPersonController Script
I have a character with a ThirdPersonController (mario64 style). The little piece of code I have here is part of the ThirdPersonController script.
Always if one of the wasd keys get pressed "isMoving" turns on.
My problem is that although everything's going great, crouching fails to work.. Does it matter that crouching is not set as an animationstate?
If I set it to a layer higher, it'll conquer any other animation underneath it.
I have no idea what's going on or what to do, I'm after all still a noob at scripting.
I do know that Walk, idle, jump and run are all set as animation states and show up in the inspector. Is it really that necessary to add a crouching animationstate?
I have the whole script here, if needed i'll post it along.
I'm an animator and i'm trying to learn the scripting part.
Thanks,
David
function Update() {
if (isMoving)
animation.CrossFade("Walk");
if (!isMoving)
animation.CrossFade("idle", .15);
if (Input.GetKey (KeyCode.C) && (!isMoving))
animation.CrossFade("CrouchIdle", 0.3);
if (Input.GetKey (KeyCode.LeftShift) && (isMoving))
animation.CrossFade("Run", .3);
if (Input.GetKey (KeyCode.C) && (isMoving))
animation.CrossFade("CrouchWalk", .3);
animation["CrouchWalk"].layer = 1;
animation["Jump"].layer = 1;
animation["Run"].layer = 1;
animation["CrouchIdle"].layer = 1;
animation["idle"].layer = 1;
animation["Walk"].layer = 1;
Your answer
Follow this Question
Related Questions
Cant assign animation to script 1 Answer
Problem playing another animations to the ThirdPersonController Script Automatically 0 Answers
Unity crashes when I add a script! 1 Answer
Character won't play animation 8 Answers
Animation / Distance 0 Answers