- Home /
Animation problem.
Hi! When i create a 2d sprite walking animation with frames and i try to use it in script. Console give me a error "The animation state could not be played because it...." And i research the reason of problem. I find a solution set animation type 2 to 1. I did it but now my animation not working why?
Please tell us whether you use an Animator
or an Animation
component on your sprite.
Ahh its solved thx. But there is a new problem :/ When character is jumping if i touch the move button its using move animation how can i fix it?
It all depends on how you implemented it. Please show us the code responsible for changing your sprite's animation.
Answer by firat0912 · Oct 11, 2014 at 07:12 PM
function Update()
{
var movement = Vector3.zero;
// Apply movement from move joystick
var movePad = moveTouchPad;
if ( movePad.IsFingerDown() )
{
move = 1f;
otherAnimator.SetFloat ("Run", move);
movement = Vector3.right * forwardSpeed;
}
// Check for jump
if ( character.isGrounded )
{
var jump = false;
var touchPad = jumpTouchPad;
if ( !touchPad.IsFingerDown() )
canJump = true;
if ( canJump && touchPad.IsFingerDown() )
{
move = 1f;
otherAnimator.SetFloat ("Jump", move);
jump = true;
canJump = false;
}
if(jump==false)
{
move = 0f;
otherAnimator.SetFloat ("Jump", move);
}
You're allowing the player to initiate a jump only if they're not moving the joystick. Fine, but nothing prevents them from moving around with the joystick after the jump was initiated, hence the issue you're experiencing.
Consider using a boolean 'can$$anonymous$$ove', not unlike the 'canJump' you're using.
PS: You shouldn't have posted your code as an answer to your question. Please try to edit your question next time.
Your answer
Follow this Question
Related Questions
My player won't jump? 1 Answer
Troubles with detecting end of animation clip using Animator in Unity2d (4.5.5) 0 Answers
Method Animator.SetBool sometimes is not working (or not triggering) in Unity2D 1 Answer
Animation not working properly in unity web player 0 Answers
Unity 2d animation acting strange 0 Answers