이 섹션에서는 설정한 장치를 런타임에 찾는 방법을 알아봅니다.
-
Verse 익스플로러를 열고 team_elimination_game.verse 를 더블클릭하여 Visual Studio Code에서 스크립트를 엽니다.
-
파일의 최상단에 다음 코드를 작성합니다.
-
elimination_result구조체를 레퍼런스하기 위해using { /Fortnite.com/Game }을 추가합니다. -
GetFortCharacter[]API를 사용하기 위해using { /Fortnite.com/Characters }를 추가합니다.
using { /Fortnite.com/Characters } using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Fortnite.com/Teams } using { /Verse.org/Simulation } -
-
team_elimination_game클래스 정의에 다음 필드를 추가합니다.-
편집 가능
item_granter_device배열 변수WeaponGranters를 추가해 플레이어에게 무기를 제공하는 데 필요한 모든 아이템 지급 장치를 저장합니다.@editable var WeaponGranters:[]item_granter_device = array{} -
integer 변수
EliminationsToEndGame을 추가해 팀이 승리하려면 플레이어 한 명이 달성해야 하는 처치 수를 나타냅니다. 한 명의 플레이어라도 최종 무기 다음까지 진행하면 해당 팀이 승리합니다.var EliminationsToEndGame : int = 0 -
EndGameDevice라는 이름의 편집 가능end_game_device를 추가해 한 팀이EliminationsToEndGame에 도달했을 때 게임을 종료합니다.@editable EndGameDevice: end_game_device = end_game_device{} -
Sentries라는 이름의 편집 가능sentry_device배열 변수를 추가해 처치를 테스트하기 위한 보초를 저장합니다.@editable var Sentries : []sentry_device = array{} -
편집 가능
player_spawner_device배열 변수PlayerSpawners를 추가해 양 팀의 플레이어 생성 패드를 저장합니다.@editable var PlayerSpawners : []player_spawner_device = array{} -
팀 배열 변수
Teams를 추가해 게임의 각 팀에 대한 레퍼런스를 저장합니다.var Teams:[]team = array{} -
team_elimination_game클래스 정의는 이제 다음과 같아야 합니다.team_elimination_game := class(creative_device): @editable EndGameDevice: end_game_device = end_game_device{} @editable var WeaponGranters:[]item_granter_device = array{} @editable var PlayerSpawners : []player_spawner_device = array{} @editable var Sentries : []sentry_device = array{} var EliminationsToEndGame : int = 0 var Teams:[]team = array{}
-
-
섬 세팅(Island Settings) 에서 설정한 팀들로
OnBegin()의Teams배열을 업데이트합니다.fort_team_collectionAPI에서GetTeams()함수를 사용하여 플레이스페이스에 있는 모든 팀 배열을 구할 수 있습니다.OnBegin<override>()<suspends> : void = # 모든 플레이어를 얻습니다 set Teams = GetPlayspace().GetTeamCollection().GetTeams() -
EliminationsToEndGame을WeaponGranters의 길이와 동일하게 설정합니다. 플레이어가 마지막 무기 다음까지 진행하면 게임이 끝나도록 만드는 설정입니다.OnBegin()코드는 이제 다음과 같아야 합니다.OnBegin<override>()<suspends> : void = # 모든 플레이어를 얻습니다 set Teams = GetPlayspace().GetTeamCollection().GetTeams() set EliminationsToEndGame = WeaponGranters.Length Print("Number of eliminations to end game is {EliminationsToEndGame}") -
Visual Studio Code로 스크립트를 저장하고, UEFN 툴바에서 Verse 를 클릭하고 Verse 코드 빌드(Build Verse Code) 를 클릭하여 레벨의 Verse로 제작된 장치를 업데이트합니다.
-
team_elimination_game 장치를 선택합니다. 디테일(Details) 패널에서 각 아이템 지급 장치(Item Granter) 를 WeaponGranters 배열에, 각 플레이어 생성 패드(Player Spawn Pad) 를 PlayerSpawners 배열에, 각 보초(Sentry) 를 Sentries 에, 게임 종료 장치(End Game Device) 를 EndGameDevice 에 추가합니다.
아이템 지급 장치를 추가하는 순서가 중요합니다! 디테일 패널의 장치 순서가 플레이어가 무기를 얻어야 할 순서와 일치하는지 확인하세요.
-
UEFN 툴바에서 세션 시작(Launch Session) 을 클릭해 레벨을 플레이테스트합니다. 레벨을 플레이테스트 할 때는
EliminationsToEndGame이WeaponGranters배열의 길이와 같아야 합니다. 로그를 통해 이 행동을 확인합니다.
다음 단계
이 튜토리얼의 다음 단계에서는 게임 시작 시 플레이어에게 무기를 할당하고 플레이어 생성 이벤트에 등록하는 방법을 알아보겠습니다.