Krazy Kart Sample

  • UGoKartMovementComponent : UActorComponent
    • Tick → !HasAuthority? LastMove = CreateMove() → SimulateMove(LastMove) :
    • Create Move(DeltaTime) ( → 현재 값을 FGoKartMove instance에 넣음 )
    • SimulateMove(FGoKartMove&)
      • Throttle, MaxDrivingForce, ActorForwardVector, AirResistance, RollingResistance, Mass, DeltaTime으로 → ApplyRotation, UpdateLocationFromVelocity // 실제 로컬에 적용하는 물리값
    • GetAirResistance() // 속도기반 공기저항 계산
    • GetRollingResistance() // 속도/중량기반 구르기 마찰저항 계산
    • ApplyRotation() ( ← 서버가 아닐떄 ) ( → Velocity 및 Rotation actor에 적용 )
    • UpdateLocationFromVelocity(DeltaTime) ( ← 서버가 아닐때 ) ( → Velocity로 Translation 적용 )

 

  • AGokart : APawn
    • SetupPlayerInputComponent(arg) ( → bind 앞,옆 이동 )
    • MoveForward(value) ( ← 키바인딩 ) ( → Throttle 값 변경 )
    • MoveRight(value) ( ← 키바인딩 ) ( → SteeringThrow값 변경 )

 

  • UGoKartMovementReplicator : UActorComponent
    • Constructor ( → bCanEverTick = true, SetIsReplicated(true) )
    • Tick
      • 자율프록시
        • MovementComponent로부터 LastMove를 얻어서, UnacknowledgedMoves에 추가
        • LastMove를 서버로 보냄
      • remote role = 시뮬프록시 ( → UpdateServerState() )
      • 시뮬프록시 ( → ClientTick() )
    • UpdateServerState(FGoKartMove) ( ← remote role이 시뮬프록시일떄 ) ( → FServerState instance를 받은 move와 // 현재 actor state값 복사 )
    • ClientTick(DeltaTime) ( ← 시뮬프록시 ) ( → 시작Loc(클라위치), 타겟Loc(서버위치), 시작속도(클라속도), 타겟속도(서버속도), 속도Derivative 5개param으로 HermiteCubicSpline 써서 보간 )
      • FMath::CubicInterp ( loc )
      • FMath::CubicInterpDerivative ( vel )
    • GetLifetimeReplicatedProps ( ← 프로퍼티 복제 ) ( → FServerState )
    • OnRep_ServeState() ( → 복제 받을시 호출 RPC )
      • 자율프록시() ( → serverstate의 트랜스폼, 벨로시티적용 / acknowledgeMove 갱신 ( ClearAcknowledgeMoves )
        • ClearAcknowledgeMoves = 각 FMove의 적용시간 비교해서, last무브 이후것만 남김 
        • MoveComponent.Simulate ( 남은 FMove 적용, 시뮬레이션 해서 위치 덮어쓰기 )

 

Puzzle Platform Sample

FileTree ( ← 사용처 / → 내용 / 없는거 arg )

  • MenuSystem
    • UMenuWidget : UUserWidget // 메뉴리스트 프레임
      • Setup() ( → 기본변수 셋업, SetInputMode(FInputModeUIOnly), bShowMouseCursor = true )
      • Teardown() ( → remove from viewport || remove from parent, SetInputMode, bShowMouseCursor ) // 자가붕괴
      • SetMenuInterface() ( → 참조변수_MenuInterface 지정 )
    • UInGameMenu : UMenuWidget // level에서 esc 메뉴
      • Init() ( → 버튼에 함수 바인딩 )
      • QuitPressed() ( → teardown 및 LoadMainMenu() ( main menu level로 이동 ) )
      •  Inherit
        • Teardown() // 자가붕괴
        • LodaMainMenu()
    • UMainMenu : UMenuWidget // 로비 메뉴
      • Constructor ( → BP클래스객체 = ConstructorHelpers::FClassFind<UUserWidget> BPClass(TEXT).Class )
      • Init ( → 버튼 바인딩 )
      • OpenMainMenu() ( → menuswitcher(U위젯스위처).SetActiveWidget(타겟자식위젯 or 인덱스)
      • HostServer() ( → MenuInterface ( UEditableTextBlock위젯.Text.Tostring )
      • SelectIndex ( int ) ( → int 번호 var에 저장 후, UpdateChildren() )
      • UpdateChildren() ( → var에 저장된 int번호기준, 선택된거 "선택상태", 나머지 "비선택상태"로 변경 bool UServerRow.Selected)
      • OpenJoinMenu() ( → 위젯스위처에서 join메뉴 활성, RefreshServerList() )
      • OpenMainMenu() (→ 위젯스위처에서 MainMenu 활성 )
      • QuitPressed() ( → ConsoleCommand("quit") )
      • Inherit (MenuWidget)
        • MenuInterface ( 만들서버이름 )
    • IMenuInterface : UInterface
      • Host(FString)
      • Join(uint)
      • LoadMainMenu()
      • RefreshServerList()
    • UServerRow : UUserWidget // 메뉴리스트 컴포넌트
      • Setup ( 부모ref, 자기 번호(부모안에서) ) ( ← 부모에서 생성 후 호출 ) ( → ref들 내부변수로 할당 및 Rowbutton 바인딩 )
      • OnClciekd() ( → 부모의 선택됨인덱스에 자기한테 부여된 번호 주입 )
  • LobbyGameMode :: AGameModeBase
    • StartGame() ( → GameInstance.StartSession // World.ServerTravel ) 
    • inherit ( game mode )
      • PostLogin ( APlayerController ) ( → 인원수 체크 / 다모이면 StartGame() )
      • Logout ( APlayerController ) ( → 인원수 감소 )
  • PP.GameInstance : UGameInstance, IMenuInterface
    • Function
      • Init()
      • LoadMenuWidget() ( Menu ← MenuClass // Menu.Setup // Menu.SetMenuInterface(this) ) // 인터페이스를 통함
      • InGameLoadMenu() ( InGameLoadMenu ← InGameLoadMenuClass // InGameLoadMenu.Setup // InGameLoadMenu.SetMenuInterface(this) ) // 인터페이스를 통함
      • StartSession() ( → SessionInterface.StartSession(세션이름) )
      • CreateSession() ( → SessionInterface.CreateSession( 호스팅플레이어num, 원하는세션이름, FOnlineSessionSettings )
      • OnCreateSessionComplete(FName SessionName, bool Success) ( ← SessionInterface.OncreateSessionCompleteDelegates.Add ) when Init ( → Menu.Teardown() // World.ServerTravel(레벨파일경로?listen) )
      • OnDestroySessionComplete(FName SessionName, bool Success) ( ← SessionInterface.OnDestoySessionCompleteDelegates.Add ) when Init
      • OnFindSessionsComplete(bool Success) ( ← SessionInterface.OnFindSessionsCompleteDelegates.Add ) when Init
      • OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result) ( ← OnJoinSessionCompleteDelegates ) when Init ( → GetFirstLocalPlayerController로 자기 PC 얻고 // PC.ClientTravel(ip주소, ETravelType )
      • OnNetworkFailure ( UWorld* World, UNetDriver* NetDriver, ENetworkFailure::Type FailureType, const FString& ErrorString ) ( ← GEngine.OnNetworkFailure().Add )
      • Inherit ( Interface )
        • Host(FString) ( → 원하는 세션이름 받고(arg) // 세션있으면 기존세션 제거 // 없으면 CreateSession() )
        • Join(uint) ( → Menu 끄고 // SessionInterface.JoinSession(유저번호, 세션이름, FOnlineSessionSearchResult ( session search시 참조로 받아올 수 있는 structure )
        • LoadMainMenu() ( → PC.ClientTravel() )
        • RefreshServerList() ( → SessionInterface.FindSession(탐색플레이어num, TSharedRef<FOnlineSessionSearch>)
    • Property
      • TSubclassOf<UUserWidget> MenuClass ( ← ContructorHelpers::FClassFinde<UUserWidget> MenuBPClass(TEXT(경로)) + MenuBPClass.class ) when Construct
      • TSubclassOf<UUserWidget> InGameMenuClass ( ← ContructorHelpers::FClassFinde<UUserWidget> InGameMenuBPClass(TEXT(경로)) + InGameMenuBPClass.class ) when Construct
      • MainMenu* Menu
      • IOnlinSessionPtr SessionInterface
      • TSharedPtr<FOnlineSessionSearch> SessionSearch
      • FString DesiredServerName
  • PP.GameMode
    • Construct()
      • DefaultPawnClass = BP;

외부파일

 

  • DefaultEngine.ini
    • [/Script/EngineSettings.GameMapsSettings]
      •  TransitionMap=/Game/PuzzlePlatforms/Maps/Transiton.Transiton ( seamless travel을 위한 map 설정 )
    • [/Script/Engine.GameEngine]
      • +NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
    • [OnlineSubsystem]
      • DefaultPlatformService=Steam
    • [OnlineSubsystemSteam]
      • bEnabled=true
      • SteamDevAppId=480
    • [/Script/OnlineSubsystemSteam.SteamNetDriver]
      • NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
  • Projectname.uproject
    • "Plugins": [ { "Name": "OnlineSubsystemSteam", "Enabled": true } ]
  • Projectname.Build.cs
    • PublicDependencyModuleNames.AddRange( "OnlineSubsystemStea" )

 

 

'Unreal > Network' 카테고리의 다른 글

구조 & 개념  (0) 2024.05.21
기본 구조  (0) 2024.05.21

+ Recent posts