대화 개체를 통해 사용자는 플레이어가 선택 목록을 사용하여 대화할 수 있는 비플레이어 캐릭터(NPC)를 만들 수 있습니다.대화 개체는 인간형의 머리와 같은 부분에 삽입될 수 있으며, 플레이어는 부분 위에 있는 대화 거품을 클릭하여 대화를 시작할 수 있습니다.장소의 크리에이터는 대화에 DialogChoice 개체를 삽입하여 플레이어가 말할 수 있는 선택 사항을 선택할 수 있습니다.
요약
속성
대화 상자가 한 번에 여러 플레이어에 의해 사용될 수 있는지 여부를 설정합니다.
플레이어가 대화의 부모에서 대화를 시작할 수 있는 가장 먼 거리.
작별 옵션을 표시할지 여부를 전환합니다.
채팅이 끝날 때 대화 상자에 표시할 문장을 설정합니다. Sets the sentence that the dialog will show to the player when the chat ends.
true이면 이 대화는 최소 하나의 플레이어에 의해 사용되고 있습니다.
채팅이 시작되면 플레이어에게 표시할 첫 번째 문장을 설정합니다.
초기 대화 상자에 표시되는 아이콘을 설정합니다.
NPC의 대화 거품 색상을 설정합니다.
대화 상자가 트리거될 수 있는 최대 거리를 설정합니다.
대화의 부모에 대한 대화 오프셋을 설정합니다.
메서드
현재 대화를 사용하는 플레이어 목록을 반환합니다.
이벤트
플레이어가 어떤 것을 말할지 선택할 때, Dialog 인스턴스를 통해 발사됩니다.
속성
BehaviorType
대화 상자의 동작 유형은 여러 플레이어가 한 번에 대화 상자와 상호작용할 수 있는지 여부를 결정합니다.이 속성의 기본값은 SinglePlayer입니다.
싱글 플레이어
대화가 단일 플레이어로 구성되면 한 번에 하나의 플레이어만 대화와 상호작용할 수 있습니다.플레이어가 대화에 참여하는 즉시 다른 플레이어는 첫 번째 플레이어가 완료될 때까지 대화를 시작할 수 없습니다.
플레이어가 대화에 참여하는 동안 다른 플레이어는 대화를 시작한 플레이어의 대화 선택과 응답을 함께 볼 수 있습니다.
여러 플레이어
대화가 여러 플레이어로 설정되어 있으면 다른 플레이어가 이미 대화를 시작했더라도 언제든지 플레이어가 대화를 시작할 수 있습니다.그러나 싱글 플레이어와는 달리, 여러 플레이어로 설정된 대화는 대화 선택과 응답을 대화 상대가 아닌 대화 참여자에게 표시하지 않습니다.
local Workspace = game:GetService("Workspace")local singlePlayerDialog = Instance.new("Dialog")local singlePlayerPart = Workspace.SinglePlayerPartsinglePlayerDialog.BehaviorType = Enum.DialogBehaviorType.SinglePlayersinglePlayerDialog.InitialPrompt = "Only one person can interact with me at once."singlePlayerDialog.Parent = singlePlayerPartlocal multiplePlayersDialog = Instance.new("Dialog")local multiplePlayersPart = Workspace.MultiplePlayersPartmultiplePlayersDialog.BehaviorType = Enum.DialogBehaviorType.MultiplePlayersmultiplePlayersDialog.InitialPrompt = "Any number of players can interact with me at once."multiplePlayersDialog.Parent = multiplePlayersPart
GoodbyeChoiceActive
작별 옵션을 표시할지 여부를 전환합니다. true이면 대화 상자에 다른 대화 상자 선택 후의 마지막 옵션으로 Dialog.GoodbyeDialog의 콘텐츠가 표시됩니다.작별 옵션을 클릭하면 대화 상자가 종료됩니다.
GoodbyeDialog
채팅이 끝날 때 대화 상자에 표시할 문장을 설정합니다.Sets the sentence that the dialog will show to the player when the chat ends
메서드
GetCurrentPlayers
대화 상자의 GetCurrentPlayers 함수는 Player 현재 대화 상자를 사용하는 목록을 반환합니다.대화 상자를 사용하는 플레이어가 없으면 반환된 목록이 비어집니다.
반환
코드 샘플
local dialog = script.Parent
local function onChoiceSelected(_player, _choice)
local currentPlayers = dialog:GetCurrentPlayers()
print("The current players in the dialog:")
for _, player in ipairs(currentPlayers) do
print(player)
end
end
dialog.DialogChoiceSelected:Connect(onChoiceSelected)
이벤트
DialogChoiceSelected
플레이어가 어떤 것을 말할지 선택할 때, Dialog 인스턴스를 통해 발사됩니다.
이 이벤트는 클라이언트 측 전용이며 서버에서 발생하지 않습니다.그것은 어떤 LocalScript 또는 어떤 ModuleScript 에 필요한 연결되어야 하며, 이는 어떤 LocalScript 에 의해 요구됩니다.