I’m making a speedrun/platformer game, and I have a dash and slide function, I’m trying to make the slide speed you up to my set speed, then you will slowly slow down to normal speed, (also any type of movement will override this and you will go back to normal speed and this slide is kinda like a fortnite slide if you know what I mean, you will slide, then slow down after you reach your top speed, then after a bit you go back to walking) but everything I try wont work, here is my slide code. (there is more code but I don’t think that is necessary right now)
public float slidingPower;
public float slidingTime;
public float slidingCoolDown;
private IEnumerator Slide()
{
if (isGrounded && canSlide)
{
canSlide = false;
isSliding = true;
float slideSpeed = slidingPower;
float originalGravity = rb.gravityScale;
rb.gravityScale = 0f;
rb.velocity = new Vector2(transform.localScale.x * slideSpeed, 0f);
tr.emitting = true;
yield return new WaitForSeconds(slidingTime);
tr.emitting = false;
rb.gravityScale = originalGravity;
isSliding = false;
yield return new WaitForSeconds(slidingCoolDown);
canSlide = true;
}
Is the player not sliding at all or does it keep sliding after it is supposed to stop?
– Waterstudios11He will stop sliding after a set time I put down in unity, but then it's the same as the dash in my game, I want it to be more of an actual slide if that makes sense.
– blu3appl3