open door with pawn
This commit is contained in:
parent
4f8c44b40f
commit
037108763f
@ -2,7 +2,7 @@
|
|||||||
[/Script/EngineSettings.GameMapsSettings]
|
[/Script/EngineSettings.GameMapsSettings]
|
||||||
EditorStartupMap=/Game/NewMap.NewMap
|
EditorStartupMap=/Game/NewMap.NewMap
|
||||||
GameDefaultMap=/Game/NewMap.NewMap
|
GameDefaultMap=/Game/NewMap.NewMap
|
||||||
GlobalDefaultGameMode="/Script/RoomEscape.RoomEscapeGameMode"
|
GlobalDefaultGameMode=/Script/RoomEscape.RoomEscapeGameModeBase
|
||||||
|
|
||||||
[/Script/HardwareTargeting.HardwareTargetingSettings]
|
[/Script/HardwareTargeting.HardwareTargetingSettings]
|
||||||
TargetedHardwareClass=Desktop
|
TargetedHardwareClass=Desktop
|
||||||
@ -51,4 +51,3 @@ AsyncSceneSmoothingFactor=0.990000
|
|||||||
InitialAverageFrameRate=0.016667
|
InitialAverageFrameRate=0.016667
|
||||||
PhysXTreeRebuildRate=10
|
PhysXTreeRebuildRate=10
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +7,10 @@
|
|||||||
// Sets default values for this component's properties
|
// Sets default values for this component's properties
|
||||||
UOpenDoor::UOpenDoor()
|
UOpenDoor::UOpenDoor()
|
||||||
{
|
{
|
||||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
// Set this component to be initialized when the game starts, and to be ticked every frame.
|
||||||
|
// You can turn these features
|
||||||
// off to improve performance if you don't need them.
|
// off to improve performance if you don't need them.
|
||||||
PrimaryComponentTick.bCanEverTick = true;
|
PrimaryComponentTick.bCanEverTick = true;
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -20,26 +19,28 @@ void UOpenDoor::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
AActor* Owner = GetOwner();
|
|
||||||
FString ObjectName = Owner->GetName();
|
|
||||||
|
|
||||||
|
|
||||||
FString Rot = Owner->GetTransform().GetRotation().GetAxisZ().ToString();
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("%s is at: %s"), *ObjectName, *Rot);
|
|
||||||
|
|
||||||
|
|
||||||
FRotator NewRotation = FRotator(0.0f, -90.0f, 0.0f);
|
|
||||||
|
|
||||||
Owner->SetActorRotation(NewRotation);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UOpenDoor::OpenDoor() {
|
||||||
|
AActor* Owner = GetOwner();
|
||||||
|
FString ObjectName = Owner->GetName();
|
||||||
|
FString Rot = Owner->GetTransform().GetRotation().GetAxisZ().ToString();
|
||||||
|
FRotator NewRotation = FRotator(0.0f, -90.0f, 0.0f);
|
||||||
|
Owner->SetActorRotation(NewRotation);
|
||||||
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
// ...
|
// poll the TriggerVolume every frame
|
||||||
|
// if ActorThatOpens is in the volume, open door
|
||||||
|
if (PressurePlate->IsOverlappingActor(ActorThatOpens)) {
|
||||||
|
OpenDoor();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class ROOMESCAPE_API UOpenDoor : public UActorComponent
|
|||||||
public:
|
public:
|
||||||
// Sets default values for this component's properties
|
// Sets default values for this component's properties
|
||||||
UOpenDoor();
|
UOpenDoor();
|
||||||
|
void OpenDoor();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
@ -33,4 +34,6 @@ private:
|
|||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
ATriggerVolume* PressurePlate;
|
ATriggerVolume* PressurePlate;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
AActor* ActorThatOpens;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user