Forum rules - please read before posting.

[Feature Request] Interaction Inspector: Player Line

edited November 2020 in Engine development

Hello,

in 90% of the "Look at", and in 60-70% of my "Use" interactions I just have the player to say something.
So it would be a great feature not to create an "Interaction" for this all the time, but just being able to add the Players "line" in the inspector (Like the "walk to marker", ...)

Something like:
Mockup

Someone else who would find this helpful?

Best,
Kai

Comments

  • edited November 2020

    The dedicated speech Action has more under the hood besides the text itself - animation options, translation and audio data etc - so a dedicated field in the Hotspot component itself would be too limiting for official inclusion.

    However, since ActionLists can be generated at runtime through scripting, it's possible to attach a component that generates a speech Action automatically when a Hotspot is looked at:

    using System.Collections.Generic;
    using UnityEngine;
    using AC;
    
    public class ExamineHotspotSpeech : MonoBehaviour
    {
    
        public string speechText;
        private int lookIconID = 1; // Change this as necessary
    
        private void OnEnable () { EventManager.OnHotspotInteract += OnHotspotInteract; }
        private void OnDisable () { EventManager.OnHotspotInteract -= OnHotspotInteract; }
    
        private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
        {
            if (hotspot == GetComponent <Hotspot>())
            {
                if ((hotspot.GetButtonInteractionType () == HotspotInteractionType.Use && button.iconID == lookIconID) ||
                    hotspot.GetButtonInteractionType () == HotspotInteractionType.Examine)
                {
                    ActionList actionList = CreateActionList ();
                    actionList.Interact ();
                }
            }
        }
    
        private ActionList CreateActionList ()
        {
            ActionList actionList = gameObject.GetComponent <ActionList>();
            if (actionList) return actionList;
    
            actionList = gameObject.AddComponent <ActionList>();
            actionList.actions = new List<Action>
            {
                ActionSpeech.CreateNew (KickStarter.player, speechText),
            };
    
            return actionList;
        }
    
    }
    

    See the Manual's "Interaction scripting" and "Generating ActionLists through script" chapters for details on the techniques the above script uses, but attaching this to a Hotspot - and giving it a Look At interaction with no ActionList - should trigger speech.

  • Thanks for the script @ChrisIceBox . I'll give it a try.

    Still, from an usability perspective, the dedicated field would be a very straight forward solution, to cover a big amount of the interactions I have. And it seems the script for this is already existing. :)
    But I can survive without it ;)

    Keep up the great work! AC is awesome.

    Best
    Kai

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.