Forum rules - please read before posting.

Change a hotspot's "player action" (walk to/turn/do nothing...)

Is there a painless way to change this property of a hotspot interaction through an action list? I'm looking for something I could put in a generic AL with a parameter, and run for every hotspot I need to change the action to.

The scenario is that we're at the end game and it takes place in a previously visited scene, full of now superfluous hotspots. I want the player to focus on the task at hand, but at the same time I don't want to just turn off all old hotspots. Most hotspots have a "walk to marker" action on the use interaction, and it feels silly for the player to walk up to a hotspot and just say "now it's not the time". So I'd like to change that "walk to" into "do nothing" for all of these old hotspots.

I thought I could add a second "use" action with "do nothing" for every hotspot, disable the old one and enable the new one, but it doesn't work for me for a couple of reasons: it doesn't work if I pass the hotspot as a parameter (so I would have to do it manually for each one) and I want to also change the examine "player action", but I can't add a second examine action.

Comments

  • Not built-in, but you can control this property through a custom script function that you can then call via an ActionList using the Object: Call event Action:

    public Hotspot[] hotspotsToAffect;
    
    public void SetToDoNothing ()
    {
        foreach (Hotspot hotspot in hotspotsToAffect)
        {
            if (hotspot == null) continue;
    
            if (hotspot.HasContextUse ())
            {
                foreach (var useButton in hotspot.useButtons)
                {
                    useButton.playerAction = PlayerAction.DoNothing;
                }
            }
    
            if (hotspot.HasContextLook ()) 
            {
                hotspot.lookButton.playerAction = PlayerAction.DoNothing;
            }
        }
    }
    
  • edited January 2

    Hi Chris, thanks a lot
    If anyone's interested I transformed this into a custom action script that can change the playerAction either way

    using UnityEngine;
    using System.Collections.Generic;
    
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ChangePlayerAction : Action
        {
    
                    public GameObject objectToAffect;
                    public Hotspot hotspotToAffect;
                    public PlayerAction useAction;
                    public PlayerAction examineAction;
                    public int useActionInt;
                    public int examineActionInt;
                    public readonly string[] options = { "Unchanged", "DoNothing", "TurnToFace", "WalkToMarker"};
    
    
                    public override ActionCategory Category { get { return ActionCategory.Custom; }}
                    public override string Title { get { return "Modify hotspot player action"; }}
    
    
                    public override float Run ()
                    {
                        hotspotToAffect = objectToAffect.GetComponent<Hotspot>();
    
                        if (!objectToAffect || !hotspotToAffect) {
                            Debug.Log("exiting ChangePlayerAction - no hotspot found");
                            return 0f;
                        }
    
                        if (hotspotToAffect.HasContextUse ())
                        {
                            foreach (var useButton in hotspotToAffect.useButtons)
                            {
                            if (useActionInt == 1) {
                                useAction = PlayerAction.DoNothing;
                            }
                            else if (useActionInt == 2) {
                                useAction = PlayerAction.TurnToFace;
                            }
                            else if (useActionInt == 3) {
                                useAction = PlayerAction.WalkToMarker;
                            }
                            else {
                                useAction = useButton.playerAction;
                            }
    
                                    useButton.playerAction = useAction;
                            }
                        }
    
                        if (hotspotToAffect.HasContextLook ()) 
                        {
    
                            if (examineActionInt == 1) {
                                examineAction = PlayerAction.DoNothing;
                            }
                            else if (examineActionInt == 2) {
                                examineAction = PlayerAction.TurnToFace;
                            }
                            else if (examineActionInt == 3) {
                                examineAction = PlayerAction.WalkToMarker;
                            }
                            else {
                                examineAction = hotspotToAffect.lookButton.playerAction;
                            }
    
                            hotspotToAffect.lookButton.playerAction = examineAction;
                        }
    
                        return 0f;
            }
    
            public override void Skip ()
            {
                 Run ();
            }
    
    
                    #if UNITY_EDITOR
    
                    public override void ShowGUI (List<ActionParameter> parameters)
                    {
                            objectToAffect = (GameObject) EditorGUILayout.ObjectField("Hotspot to affect:", objectToAffect, typeof (GameObject), true);
                            useActionInt = EditorGUILayout.Popup("Use action", useActionInt, options);
                            examineActionInt = EditorGUILayout.Popup("Examine action", examineActionInt, options);
                    }
    
                    #endif
    
            }
    
    }
    
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.