Hey guys! Sorry for this no0b question but I’m kinda stuck.
The setup: I have an animation script that is based on input from the player. you press left = walkLeft animation. this works well for a Left-Right and also for runs and idle that activates when you don’t have any input.
But the jumps are “digital” meaning that if i press the button marked “jump” once, the character is jumping the same height as it would if you pressed and held down the button. This is causing my animation to disappear once I released the jump button ( and also give some unwanted results on the landing, IE nothing).
So working with the animation script a while, i thought it would be easier if i just accessed the CollisionFlags.Below and made the animation play depending on if the collider is hitting something below or not.
example code:
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
if (controller.collisionFlags CollisionFlags.Below)
{
//If I land on something I first play the Land animation once.
animation.wrapMode = WrapMode.Once;
animation.CrossFade("jumpLand");
}
//If I'm not standing on the ground.
else
{
//Plays these animations only once
animation.wrapMode = WrapMode.Once;
animation.CrossFade("jumpStart");
animation.PlayQueued("jumpIdle", QueueMode.CompleteOthers);
//After finishing with the start section of the jump
//the jumpFall will loop until the "if" is broken.
animation.wrapMode = WrapMode.Loop;
animation.CrossFade("jumpFall");
}
}
Now my questions are
-
Do I need to make an For-loop to make sure the jumpStart and jumpLand will only be played once?
-
How can I specify what CharacterController I want to use if I’m not attaching this script to the CharacterController itself?
Thanks!