Get 25% off your next order from the Unity Asset Store: YW86GYBU8S.
Forum begins after the advertisement:
[Part 2] No Response with Dashing
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 2] No Response with Dashing
- This topic has 2 replies, 2 voices, and was last updated 6 months, 3 weeks ago by
Doctor Frostbloom.
-
AuthorPosts
-
April 11, 2025 at 7:55 am #17880::
I’ve ran into a unique issue in which the character cannot dash, as if no code exists for it in the database. I’ve fixed it as best as I can (I even got a
NullReferenceExceptionat one point but it was because I missed a code string and now the character works again), but now not a single coding response happens. All the code for the dashing has been implemented, the character has no irregularities with movement, the keybind for dashing has been set, but no dash happens. Here’s the.zipfor my game in case it’s needed since that might be the only way to solve this (I genuinely don’t know where the problem is, code seems fine as does the projectsettings): https://drive.google.com/drive/folders/102fp9N7NNH6vljSeoOXC2fti674eaqKZ?usp=sharing Please help me with this so I can not only learn from it but also continue my programming adventure.April 11, 2025 at 2:58 pm #17881::You are unable to dash because in your
PMovementscript, thecanDashvariable is never initialised. This means that it is false by default. Initialise it to true by default.[Header("Dash Settings")] [SerializeField] private float dashSpeed; [SerializeField] private float dashTime; [SerializeField] private float dashCooldown; [Space(5)] PlayerStates pState; private float xAxis; private float gravity; private Rigidbody2D rb; Animator anim; private bool canDash = true; private bool dashed;Otherwise your dash condition never gets fulfilled:
void StartDash() { if(Input.GetButtonDown("Dash") && canDash && !dashed) { StartCoroutine(Dash()); dashed = true; } if (Grounded()) { dashed = false; } }In future, paste the codes you think have issues here so I can have a look at the code directly. It is not very convenient for me to open your project every time you run into an issue.
April 12, 2025 at 6:48 am #17892::Ah, thank you so much! Sorry for not uploading the code, I just didn’t know where the issue was so I wanted to cover all the bases in case it wasn’t a code problem and a settings problem. But it was a code problem, so I’ll make sure that if I run into more issues, I’ll post the code first! Thank you again so much for helping me with this!
has upvoted this post. -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: