Thanks!

I learnt a lot during this course!

To finish it, I’m very proud to have fixed two flaws Ben’s talked about :smiley:

First, the door that was spamming each tick
I implemented an OnEndOverlap Event:

Header:

UFUNCTION()
void OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

Implementation:

void UOpenDoor::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
	OnDoorClose.Broadcast();
}

And then called in tick brackets:

	if (GetTotalMassOfActor() >= TriggerMass) {
		OnDoorOpen.Broadcast();	
	}
	else {
		PressurePlate->FindComponentByClass<UPrimitiveComponent>()->OnComponentEndOverlap.AddDynamic(this, &UOpenDoor::OnOverlapEnd);
	}

Secondly, i’m so glad i could implement a UStruct to store PlayerReachStart and PlayerReachEnd and cut the number of lines of Grabber.cpp to 114

Header (Before the class declaration):

USTRUCT()
struct FPlayerReach
{
	GENERATED_BODY()

	UPROPERTY()
	FVector ReachStart;
	UPROPERTY()
	FVector ReachEnd;

	FPlayerReach() {
		ReachStart = FVector(0,0,0);
		ReachEnd = FVector(0, 0, 0);
	}
};

Then I could Make only one function returning the two vectors to get PlayerReach start and end in one shot. Super handy, cleaner, clearer :slight_smile:

Privacy & Terms