Animations and Animator don't work - 2D Platformer Game for Android
Hi guys, actually I don't know where I should start from but I'll try to explain my problem. Because it makes me crazy, because my animations don't work even though I don't get any error.
Before I added character selector page, my main character was working properly. But then jump, walk and run animations stop working. I deleted character selector page and scripts but still dont work. I didn't change anything. I just saved my main character as a prefab. That's all. Whatever I've tried, animator and animations don't work even though I created new project and did the same like before stop working. I'd be so glad, if you help me. Thank you so much in advance.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float walkSpeed;
public float jumpSpeed;
public float doubleJumpSpeed;
internal bool canDoubleJump;
public bool isGrounded;
Transform groundCheck;
const float groundCheckRadius=0.2f;
public LayerMask groundLayer;
Rigidbody2D rb;
Animator playerAnimController;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void Start()
{
playerAnimController = GetComponent<Animator>();
groundCheck = transform.Find("groundCheck");
}
void Update()
{
transform.Translate(walkSpeed * Time.deltaTime, 0, 0);
updateAnimations();
}
void FixedUpdate() {
isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);
}
void updateAnimations() {
playerAnimController.SetFloat("VelocityX",Mathf.Abs(rb.velocity.x));
playerAnimController.SetBool("isGrounded", isGrounded);
playerAnimController.SetFloat("VelocityY", rb.velocity.y);
}
public void DoubleJump() {
if (isGrounded)
{
rb.AddForce(new Vector2(0, jumpSpeed));
canDoubleJump = true;
}
else if (!isGrounded && canDoubleJump) {
canDoubleJump = false;
rb.AddForce(new Vector2(0, doubleJumpSpeed), ForceMode2D.Impulse);
}
}
}
!
Your answer
Follow this Question
Related Questions
Need Advice on Rotation Animation with 2D Blendtree 0 Answers
Can't play an animation from the Animator 1 Answer
Copied character(enemy) not run the animations 0 Answers
Transitions quickly play twice before ingaging properly, 0 Answers
Animation looks super janky while the game is running 0 Answers