Nothing is getting triggered

Hi,

I’ve done everything [including sorting out the all the headers] but nothing triggers the door [or anything else for that matter]. I’ve gone through everything, and even added breakpoints to “TickComponent” which never seems to get called.

Can’t work out whats going wrong here.

Nothing in the video’s works for me when it comes to TriggerVolume! I’ve scrapped the trigger volume twice and played around with the settings and nothing works. I can freeze the game and exit the actor, but when I move through the triggervolume it does nothing and the break points don’t even stop the code!

Any ideas?

Here’s my code

OpenDoor.h

// Copyright Barry Robinson © all rights reserved

#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(EditAnywhere)
float mDoorOpenAngle = 95.0f;

UPROPERTY(EditAnywhere)
ATriggerVolume * mPreasurePlate;

UPROPERTY(EditAnywhere)
AActor * mActorToOpenDoor;

};

OpenDoor.cpp

// Copyright Barry Robinson © all rights reserved
#include “OpenDoor.h”
#include “GameFramework/Actor.h”
#include “Engine/World.h”
#include “GameFramework/PlayerController.h”

// Sets default values for this component’s properties
UOpenDoor::UOpenDoor()
{
// Nothing to set up as the value was moved into the class definition.
}

// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();

mActorToOpenDoor = GetWorld()->GetFirstPlayerController()->GetPawn();

// 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.
PrimaryComponentTick.bCanEverTick = true;

}

void UOpenDoor::OpenDoor()
{
// Get the door owner
AActor * Door = GetOwner();

// Get the current rotation state
FRotator ActorRotation = Door->GetActorRotation();

// Set the Yaw to 235 [dependant on the initial position of the door] 
ActorRotation.Yaw = mDoorOpenAngle;

// Then set the rotation to open the door
Door->SetActorRotation(ActorRotation);

}

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// Each tick see if the actor has colided wit the trigger volume 
if (mPreasurePlate->IsOverlappingActor(mActorToOpenDoor))
{
	// If it has open the door
	OpenDoor();
}

}

The line above must go in the constructor, not in BeginPlay().

Privacy & Terms