❔ 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
How are you doing it currently?
$ask
How to get the best help
Make a post in #help or one of the topic channels under Development.
Avoid asking Can anybody help Has anyone used 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.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)
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
Please use $paste as it is easier to read.
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!
ohhhhhh
I just screenshot
i need to change the serializefield part too
im acc so sorry i got no idea what im doing
so what happens when u try to dash?
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.