-
Notifications
You must be signed in to change notification settings - Fork 295
/
VoxelCharacter.h
35 lines (31 loc) · 1.13 KB
/
VoxelCharacter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Voxel Plugin SAS. All Rights Reserved.
#pragma once
#include "GameFramework/Character.h"
#include "Components/PrimitiveComponent.h"
#include "VoxelCharacter.generated.h"
UCLASS(BlueprintType)
class VOXEL_API AVoxelCharacter : public ACharacter
{
GENERATED_BODY()
public:
// You can copy/paste this function to your own character class
// You might have to add
// #include "Components/PrimitiveComponent.h"
// at the top of your character header
// This function is required for base replication to work properly, as voxel world components are generated at runtime & not replicated
virtual void SetBase(UPrimitiveComponent* NewBase, FName BoneName, bool bNotifyActor) override
{
if (NewBase)
{
AActor* BaseOwner = NewBase->GetOwner();
// LoadClass to not depend on the voxel module
static UClass* VoxelWorldClass = LoadClass<UObject>(nullptr, TEXT("/Script/Voxel.VoxelWorld"));
if (ensure(VoxelWorldClass) && BaseOwner && BaseOwner->IsA(VoxelWorldClass))
{
NewBase = Cast<UPrimitiveComponent>(BaseOwner->GetRootComponent());
ensure(NewBase);
}
}
Super::SetBase(NewBase, BoneName, bNotifyActor);
}
};