Forum rules - please read before posting.

Option for Run to Marker

First, Adventure Creator is an amazing asset! I am really enjoying learning to use it.

Would it be possible to add a player action to the “Use interactions/Player action” drop menu called “Run to Marker” that causes the player to run to the marker instead of walk. But then returns the player to walking state after arriving at the marker? Is this already possible and I am missing it?

Thanks and best wishes,
Jay

Comments

  • Welcome to the community, @JBacal.

    Automatically running to a Hotspot is available if the player double-clicks.

    To have this occur with a single-click, or any condition that the player interacts with a Hotspot, you can hook into AC's Hotspot events to override the Player's behaviour.

    Custom events are a way of hooking custom code into common AC tasks to add your own functionality - a tutorial can be found here.

    This code should do it. Paste into a C# script named RunToHotspots, and add to an empty GameObject in your scene:

    using UnityEngine;
    using AC;
    
    public class RunToHotspots : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnHotspotInteract += OnHotspotInteract;
            EventManager.OnHotspotReach += OnHotspotReach;
            EventManager.OnHotspotStopMovingTo += OnHotspotStopMovingTo;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotStopMovingTo -= OnHotspotStopMovingTo;
            EventManager.OnHotspotReach -= OnHotspotReach;
            EventManager.OnHotspotInteract -= OnHotspotInteract;
        }
    
        private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
        {
            KickStarter.player.runningLocked = PlayerMoveLock.AlwaysRun;
        }
    
        private void OnHotspotReach (Hotspot hotspot, AC.Button button)
        {
            KickStarter.player.runningLocked = PlayerMoveLock.Free;
        }
    
        private void OnHotspotStopMovingTo (Hotspot hotspot)
        {
            KickStarter.player.runningLocked = PlayerMoveLock.Free;
        }
    
    }
    
  • Thank you for the code.

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.