C
C#14mo ago
mani

❔ PlayerMovement

Hi, so Ive got a BASIC player movement script and wanted to implement dashing. When the player progress through the story they are able to pick up a "potion" and unlock the dashing ability. How should I go about this because I feel like I am doing it wrong.... sorry if this is bad
12 Replies
Murten
Murten14mo ago
How are you doing it currently?
Buddy
Buddy14mo ago
$ask
MODiX
MODiX14mo ago
How to get the best help catpog Make a post in #help or one of the topic channels under Development. Avoid askingcatthinking Can anybody help catthinking Has anyone used catthinking Why doesn't my code work? C# is a big area! No one knows they can help unless you tell them about the small area you're trying to work in. Explain what you are doing, and potentially why for as much context as possible. Avoid screenshots where possible, share code directly in Discord. Type $code into chat to learn how to post code. See https://www.nohello.net and https://dontasktoask.com if you want common help chat room etiquette.
Buddy
Buddy14mo ago
Please add code, and more context. We don't help with entire projects (or features if no code has been included); we do however help with certain questions. Specifically
I feel like I am doing it wrong.
- What is the system you have right now? - How does the code look? (Please post code)
mani
maniOP14mo ago
using System.Collections; using System.Collections.Generic; using UnityEngine; public class DashBuff : MonoBehaviour { [SerializeField] private playerMovement; // Reference playerMovement script?? private bool canDash = true; private bool isDashing; private float dashingPower = 24f; private float dashingTime = 0.2f; private float dashingCooldown = 1f; [SerializeField] private TrailRenderer tr; private IEnumerator Dash() { canDash = false; isDashing = true; float originalGravity = rb.gravityScale; rb.gravityScale = 0f; rb.velocity = new Vector2(transform.localScale.x * dashingPower, 0f); tr.emitting = true; yield return new WaitForSeconds(dashingTime); tr.emitting = false; rb.gravityScale = originalGravity; isDashing = false; yield return new WaitForSeconds(dashingCooldown); canDash = true; } private void Update() { if (Input.GetKeyDown(KeyCode.LeftShift) && canDash) { StartCoroutine(DashBuff()); } } } so this is the dash code - apologies for the mess I am very new and working on my own
Buddy
Buddy14mo ago
Please use $paste as it is easier to read.
MODiX
MODiX14mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
mani
maniOP14mo ago
ohhhhhh
mani
maniOP14mo ago
I just screenshot
No description
mani
maniOP14mo ago
i need to change the serializefield part too im acc so sorry i got no idea what im doing
TheRanger
TheRanger14mo ago
so what happens when u try to dash?
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server