Teleporter Conundrum

Here’s the scenario:

I’m building a level in which the player character can walk through a portal that teleports them back to the level’s starting location. I’ve done this by putting a trigger volume in a doorway, linking it to an OnActorBeginOverlap node that feeds into a Teleport node with the player character set as the target and a blank actor at the level’s starting point set as the destination location.

It works fine and all when the player character walks through it, but also present in the level are several dozen AI NPC’s that are also slowly making their way toward the portal. For the sake of the game’s story, they also need to be able to enter the portal. I’d like to rig the level so that whenever an NPC walks through the portal, it is teleported to its own starting location (not the player’s starting location). Under the current blueprint, however, whenever an NPC walks into the portal, it just teleports the **player **character back to the starting point, no matter where on the map the player character is when the NPC enters the portal.

Is there a way to rig the teleporter such that whatever actor enters the teleporter’s trigger volume, be it the player character or an AI NPC, only the actor entering the trigger volume is teleported?

One idea that comes to mind is to, within the portal, create a trigger volume for each of the NPC’s that is specific to that NPC, and to physically place the NPC’s trigger volumes in front of the player character’s trigger volume, so that any NPC entering the portal will be teleported away before they can enter the player character’s trigger volume. But that just seems over-elaborate. Anyone have any suggestions?

Thanks in advance.

What about two triggers. One only the player can overlap (maybe with character mesh on collision) and the other ‘ignore pawn’??? Just a guess, somewhere to start.

A way more simple system would be to save the NPC’s locations At Begin Play, Destroy them whenever they enter the trigger and respawn them at their original locations.

Whenever you start to create too much stuff in order to make your system work (in your case, wanting to create many volumes), you’re doing something wrong. Script is like a scientific theory: it needs to be simple and elegant. The least ad-hoc elements possible the better. :slight_smile:

@#3

“A way more simple system would be to save the NPC’s locations At Begin Play, Destroy them whenever they enter the trigger and respawn them at their original locations.”

This does seem like a more elegant approach for sure:) Is there any chance I could pick your brain further as to how to script this in blueprints? I’m fairly new to this, if it isn’t obvious, haha.

True but is a second collision box really any more complicated? :wink:

@BlakeDeGraw Pretty much gave you all the hints here buddy. Would take me a while to make a tutorial and I have a pizza to prepare.
In short, you have your NPC Blueprint. In Event Graph, you want to create a Transform variable. You want to save the world transform of your actor in that variable. Then you want to run a check (like a timer by fonction name, looping, setting the Time at 1 (second); checking every 1 second is probably enough. Avoid checking every frame, that’s all.) to know if your actor Is Valid. If False, then you can respawn.

This is the easiest quickest way I can explain to a beginner, but it’s definitely not the most elegant. It would take a while to explain the absolute most efficient one, but this should get the job done more than enough.

Hope this helps. :smiley:

Instead of having 2 triggers I would just check who is entering the trigger. That information is readily avaliable and even excludable via a simple cast node.
you can handle the 2 scenarios differently depending on what class is overlapping, or what Tags the class you overlap is assigned.
tags were created for simple stuff like this afterall…

And instead of deleting / respawning I would think that for the sheer sake of Overhead it’s easier to simply teleport the AIs then it would be to delete/re-initialize them.

the most efficient way is probably a conjunction of overlap plus Interface.
If you set up the interface and create the interface into stuff that needs to react, you can simply control what happens on overlap working within the actors themself.
look up Interfaces.

they are explained rather well within the Learn tab / academy. You want to have a look at the creating a game one… I don’t recall the exact tile, but Its the one where they have the character shooting as you move… (and there is very little content tagged under game development).