My Additions

Here’s an outline of some basic extensions I did to the building escape. Not amazing game design but just wanted to do something quickly to recap what I’d learned before moving on!

  • Made the two doors open into two new rooms. One is just a dark dead end, one has another door, trigger volume and statue in it.
  • The second trigger volume is set up to require a specific object to open the door, set via another EditAnywhere UPROPERTY, this time with type AActor*. If the TriggerActor is set in the editor, it will ignore TriggerMass and only open if that object is the trigger.
  • The chair is set as the TriggerActor in the second room. However removing the chair from the first room will mean the doors close again, so to get out of the second room you need to take the statue to the first room and place it in the trigger volume (the mass is set so that combined with the table it will open the door), and then take the chair to the second room and place it in that trigger volume.
  • If it was a real game I’d put a picture of a chair or some other cue near the second room trigger volume. Also to get the chair through the door I had to make it smaller, so it all looks a bit silly but does the job as a practice exercise!

TickComponent change:

if((TriggerActor) ? IsTriggerActorOnTrigger() : GetTotalMassOfActorsOnPlate() > TriggerMass)
{
    OnOpen.Broadcast();
} else {
    OnClose.Broadcast();
}

.

bool UOpenDoor::IsTriggerActorOnTrigger()
{
// find all the overlapping actors
TArray<AActor*> OverlappingActors;
if (!PressurePlate || !TriggerActor) { return false; }
PressurePlate->GetOverlappingActors(OUT OverlappingActors);
// iterate through them adding their masses
for (const auto& CurrentActor : OverlappingActors) {
// TotalMass += CurrentActor->GetRootPrimitiveComponent()->GetMass();
if (CurrentActor == TriggerActor) { return true; }
}
return false;
}

Nice work. Thanks for sharing this with the community.

Privacy & Terms