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
- This topic has 22 replies, 4 voices, and was last updated 2 weeks, 6 days ago by
Terence.
-
AuthorPosts
-
April 2, 2025 at 10:31 am #17767::
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!
April 2, 2025 at 10:35 am #17768::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.
April 2, 2025 at 5:49 pm #17781::@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
April 3, 2025 at 7:40 am #17814::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
April 3, 2025 at 7:40 am #17815::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:
- The player movement script
- The jumping logic (including the
Grounded()
method) - 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.
April 5, 2025 at 2:03 pm #17835::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
April 6, 2025 at 11:56 am #17842April 16, 2025 at 10:10 am #17927::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
April 16, 2025 at 10:10 am #17928::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:
-
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. -
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. -
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.
-
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.
-
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!
April 16, 2025 at 1:28 pm #17932::@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.
April 16, 2025 at 6:16 pm #17933::View post on imgur.com
here is the link to the video clip check it out i don’t know whats wrong with itApril 16, 2025 at 6:20 pm #17934::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.
April 17, 2025 at 4:50 pm #17955::@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
April 18, 2025 at 5:46 am #17958April 18, 2025 at 5:50 am #17959::If the loop time is unchecked and your jump animation is still playing multiple times, let’s go through a few more troubleshooting steps:
-
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 }
-
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 yourGrounded()
method or called from where you check for grounding. -
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.
-
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"); }
-
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!
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: