Hi, after following and fix some minor issue I face this one: my door doesnt open when overlapping the trigger volume!
So I tried to download the whole Ben project and cop[y paste the cpp and the header and still it wont work!
Maybe is something related to Unreal and it’s default settings when creating and position object in Viewport?
Im using UE Version: 4.19.2-4033788+++UE4+Release-4.19 and this is my viewport settings:
Door
VolumeTrigger
and this is my code
OpenDoor.cpp
#include "OpenDoor.h"
//#include "GameFramework/Actor.h"
//#include "GameFramework/PlayerController.h"
#include "Engine/World.h"
//#include "Components/ActorComponent.h"
// Called when the game starts
// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
// 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.
}
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
PrimaryComponentTick.bCanEverTick = true;
ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
FString ObjectName = GetOwner()->GetName();
UE_LOG(LogTemp, Warning, TEXT("I am %s"), *ObjectName);
}
void UOpenDoor::OpenDoor()
{
// Find the owning Actor
AActor* Owner = GetOwner();
// Create a rotator
FRotator NewRotation = FRotator(0.f, 0.f, 0.f);
// Set the door rotation
Owner->SetActorRotation(NewRotation);
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// Poll the trigger volume
// If the ActorThatOpens is in the volume
if (PressurePlate->IsOverlappingActor(ActorThatOpens))
{
OpenDoor();
}
}
OpenDoor.h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "OpenDoor.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class ESCAPEROOM_API UOpenDoor : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UOpenDoor();
protected:
// Called when the game starts
virtual void BeginPlay() override;
void OpenDoor();
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
UPROPERTY(VisibleAnywhere)
float OpenAngle = 90.0f;
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate;
UPROPERTY(EditAnywhere)
AActor* ActorThatOpens; // Remember pawn inherits from actor
};
@sampattuzzi or @ben or anybody else could you help me?
Thank you