Forum rules - please read before posting.

Ending a Conversation when to Far Away or trough certain Actions

Those are Qestions that arrise whilst making a VR Game with the AC. But I am sure that some other Adventure could also be Interested in that Topic, I hope I did not made a Duplicate but I sure did searched for something that fits my problem.

Now we are making a VR game and thus we cannot stop the player from moving around, or rather would not want to limit them to much. So we would like conversations to end when the player jumped to far away from the character, but also when smashing the receiver on the cabel. We want ti to end the same way as a dialog of the likes "mhmm, give me one more moment pleasse" does.

It would also be fun if certain other actions would stop it, of course, like drawing on the wall or something lie that. Ideally it would be a way to gener4ally stop all converssations and not need to define like one conversation that will be ended.

Comments

  • Welcome to the community, @Ezydenias.

    Through scripting, you can exit a Conversation using:

    AC.KickStarter.playerInput.EndConversation ();
    

    One way you might implement this in a generic way is to hook into the OnStartConversation custom event, so that you can record the active conversation and check its position against the main camera:

    using UnityEngine;
    using AC;
    
    public class EndConversationWithDistance : MonoBehaviour
    {
    
        public float maxDistance = 10f;
        private Conversation activeConversation;
    
    
        private void OnEnable ()
        {
            EventManager.OnStartConversation += OnStartConversation;
        }
    
        private void OnDisable ()
        {
            EventManager.OnStartConversation -= OnStartConversation;
        }
    
        private void OnStartConversation (Conversation conversation)
        {
            activeConversation = conversation;  
        }
    
        private void Update ()
        {
            float distance = Vector3.Distance (activeConversation.transform.position, Camera.main.transform.position);
            if (distance > maxDistance)
            {
                KickStarter.playerInput.EndConversation ();
                activeConversation = null;
            }
        }
    
    }
    

    This would require you to position the Conversation object itself at the NPC character. For more on custom events, see the Manual's "Custom events" chapter.

  • Hey Thanks Chris, that worked great. I tried to do the same with clicking conversation options via script. So that I can make inputs via voice comand, but I don't seem to find the relating code.

  • You can trigger a conversation option through script by calling the Conversation class's RunOption function, i.e.:

    myConversation.RunOption (optionIndexToRun);
    
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.