Forum rules - please read before posting.

No Run Backwards using Tank Control

Hi, would someone know how do I make the character not be able to run backwards when using Tank Controls? Thanks!

Comments

  • I will see if this can be made optional, but in the meantime you should be able to use a script to prevent it by overriding "Run" input checks while the Player is reversing:

    using UnityEngine;
    using AC;
    
    public class PreventRunningBackwards : MonoBehaviour
    {
    
        void Start ()
        {
            KickStarter.playerInput.InputGetButtonDelegate = My_GetButton;
        }
    
        private bool My_GetButton (string inputName)
        {
            if (inputName == "Run" && KickStarter.player.IsReversing ())
            {
                return false;
            }
            return Input.GetButton (inputName);
        }
    
    }
    
  • edited September 2022

    Thank you so much Chris, unfortunately I'm not able to make the script work. I'm using this script for now:

    using UnityEngine;
    using AC;

    public class PreventRunningBackwards : MonoBehaviour
    {
    public float normalRunSpeed = 3f;

    private void LateUpdate ()
    {
    
        if (KickStarter.player.IsReversing ())
        {
            KickStarter.player.runSpeedScale = KickStarter.player.walkSpeedScale;
        }
        else
        {
            KickStarter.player.runSpeedScale = normalRunSpeed;
        }
    
    
    } 
    

    }

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.