Forum begins after the advertisement:


[Part 1] Jump continues to trigger in midair

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 1] Jump continues to trigger in midair

Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #17767
    Doctor Frostbloom
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    Alright, I’ve never actually uploaded any source code before since this is my first game, but I put all the code/assets into a google drive if just that works. I don’t know how much it’ll help, but the code is all in there.

    https://drive.google.com/drive/folders/102fp9N7NNH6vljSeoOXC2fti674eaqKZ?usp=sharing

    Let me know if there’s any errors with viewing it!

    #17768
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    I’m unable to access external links or view files directly. However, you can copy and paste the relevant sections of your code here, and I’ll be happy to help you debug it!

    Please include the code for your player movement, jumping logic, and any related scripts that might be affecting the jumping behavior. This will give me a clearer picture of what might be going wrong.

    #17781
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @doctorfrostbloom I’ll need to have your Assets, Packages and ProjectSettings folder in your project to be able to open it.

    Refer to the guide here for more details.

    How to package and transfer your Unity project from one device to another
    #17814
    Doctor Frostbloom
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    Alright I’ve compiled everything you need and put it into the google drive. Hope this works now!

    (sending link again just in case) https://drive.google.com/drive/folders/102fp9N7NNH6vljSeoOXC2fti674eaqKZ?usp=drive_link

    #17815
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    I understand that you’ve compiled everything into a Google Drive folder, but unfortunately, I can’t access external links or files directly. However, I can still help you effectively if you share the relevant portions of your code right here.

    Please copy and paste the sections of your code that pertain to:

    1. The player movement script
    2. The jumping logic (including the Grounded() method)
    3. Any other scripts that might interact with the player’s jumping or grounded state

    With that information, I can help you troubleshoot the issue further.

    #17835
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Sorry for taking awhile to get back to you @doctorfrostbloom. I was down with fever for the past few days.

    I found your issue. Your Player and Ground Check GameObjects are under the Ground layer. This means that the player will always be grounded, because the Grounded() function will always detect the player’s collider as a piece of ground.

    Change it to Default and the issue should stop.

    View post on imgur.com
    #17842
    Doctor Frostbloom
    Level 4
    Participant
    Helpful?
    Up
    1
    ::

    THAT’S WHAT I THOUGHT COULD HAVE BEEN THE ISSUE AGGHHH IT WORKS NOW THANK YOU SO MUCH !!! Now I can move on to the other tutorials and learn from this. The issue’s been resolved now, thank you so much.

    has upvoted this post.
    #17927
    Pablo Nieto Montoya
    Level 2
    Participant
    Helpful?
    Up
    0
    ::

    Im working in part 1 of this tutorial and when i jump its like it does the animation twice or something I dont understand whats wrong the code is fine and i followed everything in the tutorial i added interpole to the rigidbody and i dont have the player layer in ground i need help please

    #17928
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    It sounds like the jumping animation is being triggered multiple times, which could be due to how the animation state is being managed in your code. Here are a few things to check:

    1. Animation Triggering: Ensure that your animation is set to trigger only once per jump. If you’re using a boolean to control the jumping animation, make sure it is set to false immediately after the jump is initiated.

    2. Jump Logic: Review your Jump() method to ensure that the jump animation is only triggered when the jump button is pressed and the player is grounded. You might want to add a check to prevent the animation from being triggered again until the player lands.

    3. Animator States: Check your Animator Controller to see if there are any transitions that might be causing the jump animation to play multiple times. Make sure the transitions are set up correctly and that there are no unintended conditions that could trigger the jump animation again.

    4. Debugging Animation State: You can add debug logs to see when the jump animation state is being set. This can help you identify if the jump logic is being called multiple times.

    5. Rigidbody Interpolation: While adding interpolation to the Rigidbody can help with smooth movement, it shouldn’t directly affect the animation triggering. Ensure that the animation logic is separate from the physics settings.

    Could you provide the relevant code for your jump logic and how you’re handling the animation state? This will help me give you more specific advice!

    #17932
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @pablonietomontoya if the animation is firing twice, it is likely an issue with the animation setup. If you can take a video clip of it, that will be very helpful to help identify the issue.

    #17933
    Pablo Nieto Montoya
    Level 2
    Participant
    Helpful?
    Up
    0
    ::
    View post on imgur.com
    here is the link to the video clip check it out i don’t know whats wrong with it
    #17934
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    I’m unable to access external links or view videos directly. However, I can help you troubleshoot the issue if you provide the relevant code snippets related to your jumping logic and animation handling.

    Please share the code for your jump method and how you’re managing the animation states in your Animator. This will help me understand what might be causing the jump animation to play twice.

    #17955
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @pablonietomontoya select your Player_Jump file and uncheck Loop Time. This should fix the jittering.

    If you want the animation to play slower, you will need to reduce the Sample Rate of your animation: https://stackoverflow.com/questions/59916604/how-to-change-sample-rate-in-unity

    #17958
    Pablo Nieto Montoya
    Level 2
    Participant
    Helpful?
    Up
    0
    ::

    bro i already had thew loop time unchecked it still doesnt work

    #17959
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    If the loop time is unchecked and your jump animation is still playing multiple times, let’s go through a few more troubleshooting steps:

    1. Animation Triggering Logic: Ensure your jump animation is triggered correctly. Here’s a simple way to structure your jump logic:

       private bool isJumping = false;
      
       void Update()
       {
           if (Input.GetButtonDown("Jump") && Grounded() && !isJumping)
           {
               Jump();
           }
       }
      
       void Jump()
       {
           rb.velocity = new Vector2(rb.velocity.x, jumpForce);
           isJumping = true;
           animator.SetTrigger("Jump"); // or however you trigger the jump animation
       }
      
       void OnLanding()
       {
           isJumping = false; // Call this method when the player lands
       }
    2. Landing Detection: You should have a method that detects when the player lands back on the ground and resets the isJumping variable. This could be part of your Grounded() method or called from where you check for grounding.

    3. Animator States: Check the Animator Controller to ensure that the transition from the jump animation back to the idle or run animation is set up correctly. Make sure there are clear conditions for transitioning out of the jump animation.

    4. Debugging: Add debug logs to see when the Jump() method is called and when the animation state changes. This will help identify if the jump logic is being triggered more often than expected:

       void Jump()
       {
           Debug.Log("Jump Called");
           rb.velocity = new Vector2(rb.velocity.x, jumpForce);
           isJumping = true;
           animator.SetTrigger("Jump");
       }
    5. Animation Events: If you’re using animation events, make sure they are not causing the jump animation to trigger again or reset prematurely.

    If you’re still having issues, please copy and paste your jump and animation-related code here. This will help me provide more specific guidance!

Viewing 15 posts - 16 through 30 (of 31 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: