Forum rules - please read before posting.

ToggleRun - how to disable when stopping?

Hello. I'm stumped...

AC: v.1.78.4 , Unity ver: 2022.3.0 Direct movement style game.

My player runs when I hold shift or LB on a controller and that's great. But recently I wanted to add an optional ToggleRun input as there are sometimes large areas to run through and it gets tiresome after a while to hold 2 buttons. So I set ToggleRun input to left ctrl and B on controller and it works BUT - the problem is the toggle stays on until player presses that input again. That seems to be the only way to deactivate it. I'd really prefer it if it got reset when player stops moving (so when they stop and then move again they are walking and the toggle is off). Active Inputs somehow don't react to anything ToggleRun related, not sure why... I tried adding my own code, I tried asking AI for help... but I didn't manage to crack it.

Please help?... ;)

Comments

  • This'll do it:

    using UnityEngine;
    using AC;
    
    public class StopRunning : MonoBehaviour
    {
        void Update()
        {
            if (KickStarter.player.charState == CharState.Idle)
            {
                KickStarter.player.toggleRun = false;
            }
        }
    }
    
  • Awesome :) It works, of course. Thanks!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.