Skip to main content
New Participant
September 17, 2025
Question

NPC Voice input and conversation

 

Hi dears,

I have question regarding the new updated LLM NPC, can they listen to our voice input as the release note says they should, but I cannot do it. can you help me? I like to have one to practice speaking English Language. 

Thanks. 

1 reply

gausroth
Honored Contributor
September 26, 2025
import { Component, CodeBlockEvents, Player, PropTypes } from 'horizon/core';
import { Npc } from 'horizon/npc';

class ConvoTest extends Component<typeof ConvoTest>{
    static propsDefinition = {
        trigger: { type: PropTypes.Entity, }
  };

    preStart() {
        if (!this.props.trigger) return;
        this.connectCodeBlockEvent(this.props.trigger, CodeBlockEvents.OnPlayerEnterTrigger, (player: Player) => this.OnPlayerEnterTrigger(player));
        this.connectCodeBlockEvent(this.props.trigger, CodeBlockEvents.OnPlayerExitTrigger, (player: Player) => this.OnPlayerExitTrigger(player));
    }

  start() { }

    OnPlayerEnterTrigger(player: Player) {
        console.log("OnPlayerEnterTrigger")
        const npc = this.entity.as(Npc);
        console.log("isConversationEnabled: " + npc.isConversationEnabled())
        npc.conversation.stopSpeaking()

        if (npc) npc.conversation.registerParticipant(player);
    }

    OnPlayerExitTrigger(player: Player) {
        const npc = this.entity.as(Npc);

        if (npc) npc.conversation.unregisterParticipant(player);
    }
}
Component.register(ConvoTest);

Without looking at your code I cannot tell where your going wrong but there are a few things to consider. You need to cast the NPC entity as an NPC and then register players to the conversation. I was unable to get it to work but having them listen to a player. Try this, I am adding a player to the convo when they enter a trigger. This script is attached to the NPC.

GitHub: https://github.com/Gausroth/HorizonWorldsTutorials.git Discord: https://discord.gg/hNyDQwdw4N YouTube: https://www.youtube.com/@GausRothTutorials