Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Resolved Jump animation after scene reload

Discussion in 'Editor & General Support' started by AlzakElvar, Jan 30, 2021.

  1. AlzakElvar

    AlzakElvar

    Joined:
    Jan 29, 2021
    Posts:
    2
    I have a platformer game, and once I reload the scene(if the hit a certain point(using trigger)) The jump animation no longer works.

    I am using the player controller form Brackeys 2d movement in Unity video
    Here is my script for how I am moving:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMove : MonoBehaviour
    {
    // Start is called before the first frame update
    public float runSpeed = 40f;
    float horizontalMove = 0f;
    bool jump = false;
    public CharacterController2D Controller;
    public Animator animator;
    // Update is called once per frame
    void Update()
    {
    horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
    if(Input.GetButtonDown("Jump")) {
    jump = true;
    animator.SetBool("IsJumping", true);
    }
    animator.SetFloat("Speed", Mathf.Abs(horizontalMove));

    }
    public void OnLanding(){
    animator.SetBool("IsJumping", false);
    }
    void FixedUpdate(){
    Controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
    jump = false;
    }
    }

    Note: I have linked up the objects where they are needed
     
  2. AlzakElvar

    AlzakElvar

    Joined:
    Jan 29, 2021
    Posts:
    2
    Okay nvm what I solved it

    What I did, was putting a delay between the time I wanted to detect if I was on the ground (making me idle) and me hitting the jump button