Forum rules - please read before posting.

Inventory: Picking up items & Walk/Run toggle

2»

Comments

  • Hi Chris, I've finally upgraded to 1.60.5, but I've got a little issue.

    If I click on a hotspot while being in 'Free' walk/run mode, and then switch to 'Always run', the player character starts running toward the hotspot and interacts with it after reaching it. That's great.

    But if I do it the opposite way ('Always run' to 'Free') I have the same behavior as before: the character stops on its path and the Use or Examine action runs as if he already reached the marker.

    Could you modify also that action so it behaves the same, please? ;)
  • It does exactly that for me, but I'm using AC's Active Input system and not PlayMaker.

    Try using Active Inputs if you're not already, and if you still have an issue, post the ActionLists involved so we can see what's missing.
  • Oh well... problem is I don't manage to get my head around those Unity Input thingies... It's one of those topics that even reading and reading about it, I just can't. So that's why I'm using PlayMaker Key Down actions...

    But if that is the way it is, then I'll make an effort. Thanks. :-)
  • THREAD NECROMANCY!

    So I'm adding full point & click navigation to my game and am about finished. I decided the last thing I wanted to do was get the run toggle to work. Followed the steps in this thread and got it working with the exception of the issue that Anaxtasia had where my movement is interrupted when hitting the "Free" movement type.

    Using Active Inputs. I'm not on the current version of AC because I don't want to introduce anything else into my game as it's already out in the wild.

    Here's the main Active Input actionlist:

    I'm also doing a check on scene load to make sure it keeps the toggle value from scene to scene:

    Everything is triggering properly and saving it's state when moving from scene to scene. It's just that the movement gets interrupted when "Free" is hit. It works fine if I set it to "Always Walk" but then, as you are aware, that makes me lose the double-click to run functionality and I want to give the player both options.

    Any tips?

  • I should point out that I'm on AC v1.65.1

  • It's just that the movement gets interrupted when "Free" is hit.

    I'm not clear on what you mean by this. What's the exact behaviour you're getting?

  • When I press the toggle button while running, it will trigger the "free" constrain and the player will stop moving. I would expect the player to keep progressing on their way but just transition back to walk.

  • This is caused by the instance of:

    player.EndPath ();
    

    on line 160 of ActionPlayerLock.cs. Does commenting out give you the behaviour you're looking for?

  • Unfortunately no. Now it seems to wait until I've reached my click point to actually toggle back to walk. It'll still toggle to run in the middle of my path but if I click it back to return to walking, the player continues to run until it reaches the click point and then the next time I click, the player is walking.

  • All right - I'll attempt a recreation.

  • Thanks Chris!

  • edited May 2020

    The issue is more to do with the fact that you want to force the Player to walk, despite the "Free" option allowing him to do both. Best to rely on a custom Action for this - and it also means you can do without the need for a Global Variable:

    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionTogglePlayerRun : Action
        {
    
            public ActionTogglePlayerRun ()
            {
                this.isDisplayed = true;
                category = ActionCategory.Player;
                title = "Toggle running";
            }
    
    
            public override float Run ()
            {
                if (KickStarter.player == null)
                {
                    LogWarning ("No Player found!");
                    return 0f;
                }
    
                if (KickStarter.player.runningLocked == PlayerMoveLock.AlwaysRun)
                {
                    KickStarter.player.runningLocked = PlayerMoveLock.Free;
    
                    if (KickStarter.player.IsPathfinding ())
                    {
                        KickStarter.player.GetPath ().pathSpeed = PathSpeed.Walk;
                        KickStarter.player.isRunning = false;
                    }
                }
                else
                {
                    KickStarter.player.runningLocked = PlayerMoveLock.AlwaysRun;
    
                    if (KickStarter.player.IsPathfinding ())
                    {
                        KickStarter.player.GetPath ().pathSpeed = PathSpeed.Run;
                        KickStarter.player.isRunning = true;
                    }
                }
    
                return 0f;
            }
    
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                AfterRunningOption ();
            }
    
            #endif
    
        }
    
    }
    
  • edited May 2020

    Very cool!
    I am getting some compiler errors with this action, though:

    • Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(36,5): error CS0103: The name `LogWarning' does not exist in the current context
    • Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(40,27): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
    • Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(42,24): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
    • Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(52,24): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
  • Right - forgot you're using an older release.

    Try this instead:

    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionTogglePlayerRun : Action
        {
    
            public ActionTogglePlayerRun ()
            {
                this.isDisplayed = true;
                category = ActionCategory.Player;
                title = "Toggle running";
            }
    
    
            public override float Run ()
            {
                if (KickStarter.player == null)
                {
                    Debug.LogWarning ("No Player found!");
                    return 0f;
                }
    
                if (KickStarter.playerInput.runLock == PlayerMoveLock.AlwaysRun)
                {
                    KickStarter.playerInput.runLock = PlayerMoveLock.Free;
    
                    if (KickStarter.player.IsPathfinding ())
                    {
                        KickStarter.player.GetPath ().pathSpeed = PathSpeed.Walk;
                        KickStarter.player.isRunning = false;
                    }
                }
                else
                {
                    KickStarter.playerInput.runLock = PlayerMoveLock.AlwaysRun;
    
                    if (KickStarter.player.IsPathfinding ())
                    {
                        KickStarter.player.GetPath ().pathSpeed = PathSpeed.Run;
                        KickStarter.player.isRunning = true;
                    }
                }
    
                return 0f;
            }
    
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                AfterRunningOption ();
            }
    
            #endif
    
        }
    
    }
    
  • Chris = Legend.

    I did get one last compiler error:
    Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(35,5): error CS0103: The name `Debug' does not exist in the current context

    I commented it out and I'm able to at least get it to run, although not sure if that's the best course of action. Functionality works great, though! Thanks man!

  • edited May 2020

    Ace. Thanks again. You rule. :)

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.