권한(Authority)
복제(Replication)
HasAuthority() : 자신이 서버인지 아닌지를 판별해주는 함수 (서버 : true)
#include "MovingPlatforms.h"
AMovingPlatforms::AMovingPlatforms()
{
PrimaryActorTick.bCanEverTick = true;
}
void AMovingPlatforms::BeginPlay()
{
Super::BeginPlay();
}
void AMovingPlatforms::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// 자신이 서버인 경우라면?
if (HasAuthority())
{
// 액터의 위치를 업데이트
FVector Location = GetActorLocation();
Location += FVector(Speed * DeltaTime, 0, 0);
SetActorLocation(Location);
}
}

현 상황에서 클라이언트가 화면의 물체와 충돌한다면?
- 플레이어는 물체를 통과하게 됩니다.
#include "MovingPlatforms.h"
AMovingPlatforms::AMovingPlatforms()
{
PrimaryActorTick.bCanEverTick = true;
}
void AMovingPlatforms::BeginPlay()
{
Super::BeginPlay();
}
void AMovingPlatforms::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// 자신이 서버가 아닌 경우라면?
if (!HasAuthority())
{
// 위치를 업데이트
FVector Location = GetActorLocation();
Location += FVector(Speed * DeltaTime, 0, 0);
SetActorLocation(Location);
}
}

현 상황에서 클라이언트가 화면의 물체와 충돌한다면?
- 플레이어는 물체를 통과하게 됩니다.
#include "MovingPlatforms.h"
AMovingPlatforms::AMovingPlatforms()
{
PrimaryActorTick.bCanEverTick = true;
}
void AMovingPlatforms::BeginPlay()
{
Super::BeginPlay();
// 자신이 서버인 경우라면?
if (HasAuthority())
{
// 현재 액터를 복제하기
SetReplicates(true);
// 현재 액터의 움직임을 복제하기
SetReplicateMovement(true);
}
}
void AMovingPlatforms::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// 자신이 서버인 경우라면?
if (HasAuthority())
{
// 위치를 업데이트
FVector Location = GetActorLocation();
Location += FVector(Speed * DeltaTime, 0, 0);
SetActorLocation(Location);
}
}

현 상황에서 클라이언트가 화면의 물체와 충돌한다면?
- 실제 액터가 있는 위치(서버 기준)과 동일하기 때문에 물체와 충돌하게 됩니다.
권한 및 게임 상태 관리
보안 및 부정행위 방지
일관성 유지