Forum rules - please read before posting.

Check if player is moving?

Hi all!

Is it possible to check if a player is currently moving?

The issue is I have an action list that runs in background -- and one of the actions is that the player faces an object (A) that the cursor is currently on, and a description pops up.

My issue is that when the player clicks on another object (B) to use, the action list runs for that --> but let's say the user hovers over object (A) for some reason during the time that the player is walking to (B), then the action list for (B) stops, and the player faces (A) instead.

In this case, I want the cursor to work when hovering over (A) , but I don't want to "face object" action running for (A) -- rather, I want to check if the player is moving first, and if so, then don't stop and face object (A)

If they are not moving / are stationary, then facing object (A) is ok!

Any way on how I can achieve this? Thank you!

-- AB


  • Through script, yes - IsMovingAlongPath returns True if a character is pathfinding:

    AC.KickStarter.player.IsMovingAlongPath ()
  • Thank you so much!

  • @ChrisIceBox

    Ah -- if it's not too much trouble, would you mind taking a look at my repository? This would be the latest one up on GitHub (updated today) -- the same link I referenced in my other issues.

    So for context, I went ahead and added this to a script called "Walk Checker" in the Update() function, and I attached it to my active player prefab (Finley); I am currently testing out the** Instructions scene** in my game.

    I also created a global variable called "playerIsMoving" to see if the player is currently moving -- I am then using this variable to determine whether the player should continue moving or stop and look (e.g: see the interaction "Trash Patch: Examine" in the Instructions scene). The variable looks like it is updating correctly, but --

    My issue is that it looks like the player is stopping its current movement regardless, despite me setting the interaction to "Run in Background" as opposed to "pause gameplay".

    Might you happen to know why the player is still pausing? Relevant information / scenes are included in this post :)

  • edited May 10

    **tried it out again -- it seems like the action I thought was running was not (the player facing the hotspot of interest), so it looks like that is not an issue / the flow there is correct

    However, my player does stop moving which is strange, despite the actionlist running in the background. Is there anyway I can prevent this for this hover action list? I would like the player to continue moving along the path they originally were, as opposed to stopping when hovering over a hotspot.

  • The Player stops because of the AutoExamineHotspot script running the Hotspot's Examine interaction, which halts the Player.

    To get around this, you can bypass the halting, and just run the interaction ActionList directly. In the ucustom script, replace:

    hotspot.RunExamineInteraction ();


    if (hotspot.lookButton != null && hotspot.lookButton.interaction) hotspot.lookButton.interaction.Interact ();
  • Awesome, I think this fixed it! Thank you so much!

  • When running the examine interaction directly, is it possible to set the parameters as well?

    I have "Set Interaction Parameter" components on the object the script is attached to, and I'm hoping that they get set first. It looks like they are not currently, so is there any way to fix this?

  • That'd need a reversion of the above change - Set Interaction Parameters kicks in when the Hotspot is interacted with, rather than when the Interaction ActionList is run directly.

    It might need a different approach - i.e. a "Don't stop Player movement" option in the Hotspot's Inspector. I'll have a think about what might be possible.

  • edited May 12

    Ah no worries!
    Is there any kind of workaround I could do for now?

    I'm in a bit of a tight place of incorporating beta feedback so I can have something by EOM, so I was just curious to know if there's a way I could have this functionality! :)

  • edited May 13

    I tried doing this via script today btw, but it seems to be flaky.
    It doesn't look like the description is being updated properly from time to time:

    The relevant parts is between the "START HERE" and the "END HERE" block.

    `using UnityEngine;
    using AC;
    using UnityEngine.TextCore.Text;
    using System.Collections.Generic;

    public class AutoExamineHotspot : MonoBehaviour

    // the description of the hotspot to manually set
    // when an inventory item is selected.
    private string description;
    // actionlist to run when inventory item selected
    ActionList invActionList;
    // Regular ActionList
    ActionList regularActionList;
    // active player, object (hotspot) player should face, and description
    private Char myCharacter;
    public GameObject objectToFace;
    // the hotspot that this script is attached to
    public Hotspot hotspotForScript; 
    public string hotspotDescription;
    //whether to run the default examine interaction or a new one
    public bool runDefaultList = true;
    private void Start()
        if(objectToFace == null)
            objectToFace = this.gameObject;
        // for when holding an inventory item
        // player faces hotspot, action runs in background
        invActionList = gameObject.AddComponent<ActionList>();
        invActionList.actionListType = ActionListType.RunInBackground;
        //for when regularly facing an item
        regularActionList = gameObject.AddComponent<ActionList>();
        regularActionList.actionListType = ActionListType.RunInBackground;
    private void OnEnable() { EventManager.OnHotspotSelect += OnHotspotSelect; }
    private void OnDisable() { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    private void OnHotspotSelect(Hotspot hotspot)
        // auto-run examine interaction if no inventory item selected
        if (KickStarter.runtimeInventory.SelectedItem == null ||
            //print("GAMEOBJECT NAME IS " +;
            //print("HOTSPOT NAME IS " + hotspotForScript.GetName(0));
            //print("INSTANCE ID HOTSPOT IS " + hotspot.GetInstanceID() +
            //    " AND SCRIPT HOTSPOT ID IS " + hotspotForScript.GetInstanceID());
            // check if hotspot hovered is the same hotspot that this script is attached to
            //--- START HERE ---
            if (hotspot.GetInstanceID() == hotspotForScript.GetInstanceID()){
                // run regular examine interaction
                if (runDefaultList)
                    //print("HOTSPOT DESCRIPTION IS " + hotspotDescription + " AND HOTSPOT IS " + hotspot.GetName(0));
                    //print("CURRENT HOTSPOT: " + hotspot.GetName(0) + "AND THIS SCRIPT IS ATTACHED TO " + this.GetComponent<Hotspot>().GetName(0));
                    print("CURRENT HOTSPOT IS " + hotspot.GetName(0) + ":" + hotspot.GetInstanceID());
                    ActionVarCheck checkPlayerMovement = ActionVarCheck.CreateNew_Global(24);
                    ActionVarSet setHotspotDescription = ActionVarSet.CreateNew_Global(4, hotspotDescription);
                    ActionCharFace faceHotspot = ActionCharFace.CreateNew_BodyFace(KickStarter.player, objectToFace);
                    regularActionList.actions = new List<Action> {
                        checkPlayerMovement, //whether player is moving
                        // TRUE: Just set description of hotspot
                        //FALSE: Make player face object, then set description
                    // create branching logic
                    checkPlayerMovement.SetOutputs(new ActionEnd(setHotspotDescription), new ActionEnd(faceHotspot));
                    setHotspotDescription.SetOutput(new ActionEnd(true));
                    faceHotspot.SetOutput(new ActionEnd(setHotspotDescription));
                    Debug.Log("RUNNING DEFAULT LIST, OUTPUT IS " + GlobalVariables.GetVariable("HotspotDescription").TextValue);
                } else {
                    // run defined action list 
                    if (hotspot.lookButton != null && hotspot.lookButton.interaction)
                    } else
                        print("DEFAULT INTERACTION NOT WORKING");
            //--- END HERE ---
            //Debug.Log("INSIDE 'IF' INVENTORY THING?");
            //if (hotspot.lookButton != null && hotspot.lookButton.interaction)
            //    hotspot.lookButton.interaction.Interact();
            //if (hotspot.lookButton != null && hotspot.lookButton.interaction)
            //    hotspot.lookButton.interaction.Interact();
            //    string dataStr = hotspot.lookButton.interaction.GetParameterData();
            //    Debug.Log("THE PARAMETER DATA " + dataStr.GetType().GetProperty("Value").GetValue(dataStr, null).ToString());
            //    Debug.Log("hotspot.lookButton.interaction" +;
            //    Debug.Log(" SOMETHING IS NULL -- LOOK BUTTON: "
            //        + hotspot.lookButton
            //        + " LB INTERACTION: "
            //        + hotspot.lookButton.interaction);
            //Debug.Log("INSIDE 'ELSE' INVENTORY THING?");
            // combine interactions with inventory 
            description = "Combine " +
            KickStarter.runtimeInventory.SelectedItem.label +
            " with " +
            // set description to combine interaction
            if(hotspot.gameObject.GetInstanceID() == this.gameObject.GetInstanceID())
                // make active player face the hotspot
                //    actionList.actions = new List<Action> {
                //    ActionCharFace.CreateNew_BodyFace(KickStarter.player, objectToFace),
                //    };
                //    actionList.Interact();


  • You can view the runtime-generated ActionList in the Editor window as normal - check to see if the Actions are correct there.

    I'll incorporate a "Stop movement" option into the interaction options when "Play action" is set to "Do Nothing" in the next release.

  • edited May 13

    Awesome, thank you so much!
    Might you happen to know where I can see upcoming release dates?

    Will keep my eyes peeled, thank you so much for taking this into account for your next release! :)

  • Afraid not - but you're welcome to be involved in testing. Send me a PM if so.

  • Awesome, 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.