Forum begins after the advertisement:
[Part 1-2] Common Issues & Bugfixes
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 1-2] Common Issues & Bugfixes
- This topic has 0 replies, 1 voice, and was last updated 1 month, 1 week ago by Joseph Tang.
-
AuthorPosts
-
March 22, 2024 at 7:54 pm #13608Joseph TangModerator
This post is to compile and go through some common issues that viewers and readers may face when following the Metroidvania series, as well as some solutions that may fix or solve the issues.
Some solutions given will also be under the assumptions that the code for the mechanic is 1:1 for the relevant part.
In this post, we will go through
[Part 1]- 1. Player is not Jumping
- 2. The Camera/Player is jittering/glitching
[Part 2]
- 1. Dashing mechanic does not work.
- 2. Double Jump is not working.
- 3. Dashing when left-clicking/attacking [Part 3 mechanic].
[Part 1] Movement & Camera
1. Player is not Jumping
- The Layer for
whatIsGround
has not been set on the Player. Or theFloor
has not been assigned the same Layer aswhatIsGround
. - If the values of
GroundCheck X
&GroundCheck Y
are not big enough. Ground Check Point
gameObject is not assigned or is not low enough, relative to the Player withGroundCheck Y
value included, to reach the LayerGround
beneath the player.
2. The Camera/Player is jittering/glitching.
- Set Player’s RigidBody2D to Interpolate
[Interpolation solves most jittering issues, but when the player is moving at a fast enough speed, we can see the Player jitter backwards a few frames here and there. This is caused by the Camera not being able to match the Player’s speed.]
- Set Player’s
walkSpeed
to a lower value - Or set Camera’s
followSpeed
to a higher value/[1]
Note: Setting Camera’s
followSpeed
to [1] will guarantee the Camera will follow the Player exactly.
[Part 2] Dash, Double Jump & Advanced Movement.
1. Dashing mechanic does not work.
[This issue is most commonly caused by a missing piece of code]
- Ensure that all parts of the Dashing mechanic’s code in the PlayerController script is as follows:
private bool canDash = true; private bool dashed; void Update() { GetInputs(); UpdateJumpVariables(); if (pState.dashing) return; Flip(); Move(); Jump(); StartDash(); } void StartDash() { if (Input.GetButtonDown("Dash") && canDash && !dashed) { StartCoroutine(Dash()); dashed = true; } if (Grounded()) { dashed = false; } } IEnumerator Dash() { canDash = false; pState.dashing = true; anim.SetTrigger("Dashing"); rb.gravityScale = 0; rb.velocity = new Vector2(transform.localScale.x * dashSpeed, 0); if (Grounded()) Instantiate(dashEffect, transform); yield return new WaitForSeconds(dashTime); rb.gravityScale = gravity; pState.dashing = false; yield return new WaitForSeconds(dashCooldown); canDash = true; }
2. Double Jump is not working.
[While this can be caused by missing code, the actual code for the mechanic relies on variables that can never fire if the value is left at [0]]
- Ensure all the values for Double Jump in the Inspector are set.
3. Dashing when left-clicking/attacking [Part 3 mechanic].
- Remove the “Mouse 0” keybind from “Alt Positive Button” under the Dash input from the Input Manager.
That will be all for Part 1 & 2. I will soon be updating on the common issues for Part 3 & 4.
Hopefully this can help you on any issues you may have. However, if you find that your issues weren’t addressed or is a unique circumstance, you can submit a forum post to go into detail on your problem for further assistance. -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: