killf 1 year ago
parent
commit
18d78cf21a

BIN
Content/Maps/Map000.umap


+ 14 - 7
Source/TetreeseDemo/VRCharacterBase.cpp

@@ -12,8 +12,6 @@
 #include "VRGroupBase.h"
 
 
-static FName FirstPersonCameraName(TEXT("FirstPersonCamera"));
-
 // Sets default values
 AVRCharacterBase::AVRCharacterBase(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer)
 {
@@ -26,7 +24,12 @@ AVRCharacterBase::AVRCharacterBase(const FObjectInitializer& ObjectInitializer):
 	GetMesh()->SetRelativeLocation(FVector(0, 0, -100));
 	GetMesh()->SetRelativeRotation(FRotator(0, -90, 0));
 
-	FirstPersonCamera = CreateDefaultSubobject<UCameraComponent>(FirstPersonCameraName);
+	static ConstructorHelpers::FObjectFinder<USkeletalMesh> MeshComponentAsset(TEXT("SkeletalMesh'/Game/72/zoulu.zoulu'"));
+	if (MeshComponentAsset.Succeeded()) {
+		GetMesh()->SetSkeletalMeshAsset(MeshComponentAsset.Object);
+	}
+
+	FirstPersonCamera = CreateDefaultSubobject<UCameraComponent>(FName(TEXT("FirstPersonCamera")));
 	if (FirstPersonCamera) {
 		FirstPersonCamera->SetRelativeLocation(FVector(60, 0, 15));
 		FirstPersonCamera->SetupAttachment(GetCapsuleComponent());
@@ -34,19 +37,21 @@ AVRCharacterBase::AVRCharacterBase(const FObjectInitializer& ObjectInitializer):
 
 	BeginWaitConnected_Timeline.SetTimelineLength(2);
 
-	CurveFloat = CreateDefaultSubobject<UCurveFloat>(FName("CurveFloat"));
+	CurveFloat = CreateDefaultSubobject<UCurveFloat>(FName(TEXT("CurveFloat")));
 	if (CurveFloat) {
 		CurveFloat->FloatCurve.AddKey(0, 0);
 		CurveFloat->FloatCurve.AddKey(2, 100);
 	}
 
 	FOnTimelineFloatStatic onTimelineUpdate;
-	onTimelineUpdate.BindUFunction(this, FName("OnBeginWaitConnected_TimelineUpdate"));	
+	onTimelineUpdate.BindUFunction(this, FName(TEXT("OnBeginWaitConnected_TimelineUpdate")));	
 	BeginWaitConnected_Timeline.AddInterpFloat(CurveFloat, onTimelineUpdate);
 
 	FOnTimelineEventStatic onTimelineFinished;
-	onTimelineFinished.BindUFunction(this, FName("OnBeginWaitConnected_TimelineFinished"));	
+	onTimelineFinished.BindUFunction(this, FName(TEXT("OnBeginWaitConnected_TimelineFinished")));	
 	BeginWaitConnected_Timeline.SetTimelineFinishedFunc(onTimelineFinished);
+
+	
 }
 
 // Called when the game starts or when spawned
@@ -111,7 +116,9 @@ void AVRCharacterBase::CreateGroup() {
 
 	GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
 
-	AVRGroupBase* group = GetWorld()->SpawnActor<AVRGroupBase>();
+	if (GroupClass == nullptr) GroupClass = AVRGroupBase::StaticClass();
+
+	AVRGroupBase* group = static_cast<AVRGroupBase*>(GetWorld()->SpawnActor(GroupClass));
 	group->SetActorTransform(GetActorTransform());
 
 	AttachToActor(group, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true), NAME_None);

+ 4 - 0
Source/TetreeseDemo/VRCharacterBase.h

@@ -6,6 +6,7 @@
 #include "GameFramework/Character.h"
 #include "Camera/CameraComponent.h"
 #include "Components/TimelineComponent.h"
+#include "VRGroupBase.h"
 #include "VRCharacterBase.generated.h"
 
 UCLASS()
@@ -51,6 +52,9 @@ private:
 	UPROPERTY(Category = Component, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
 	UCameraComponent* FirstPersonCamera;
 
+	UPROPERTY(EditAnywhere)
+	TSubclassOf<AVRGroupBase> GroupClass;
+
 	FTimeline BeginWaitConnected_Timeline;
 
 	UPROPERTY()

BIN
Source/TetreeseDemo/VRGroupBase.cpp


+ 1 - 1
Source/TetreeseDemo/VRGroupBase.h

@@ -16,7 +16,7 @@ class TETREESEDEMO_API AVRGroupBase : public APawn
 
 public:
 	// Sets default values for this pawn's properties
-	AVRGroupBase();
+	AVRGroupBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
 
 protected:
 	// Called when the game starts or when spawned