#Sprint button doesnt work with my script

3 messages · Page 1 of 1 (latest)

sage knoll
#
using System.Collections.Generic;
using UnityEngine;

public class Adrienaline : MonoBehaviour
{

    public float waitTime = 5;
    private void adrienaline()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            PlayerMovementAdvanced.sprintSpeed = 15f;
            StartCoroutine(Stop());
        }
    }

    public IEnumerator Stop()
    {
        yield return new WaitForSeconds(waitTime);
        PlayerMovementAdvanced.sprintSpeed = 10f;
    }

    private void Update()
    {
        adrienaline();
    }
}```
#

i dont see why the script wont let me sprint

light sleet
#

well, first of all, this script creates hanging coroutines, essentially, multiple instances of Stop() can be running at once, interfering with each other