Teleporting through a list (array) of locations in order

Hi all,

I’m trying to create a linear path of teleport locations that the player can teleport between.

So when the player presses “A”, they move to “Location 1”. If they press “A” again, they move to “Location 2”. If they press “A” again, they move to “Location 3”, etc etc.

If they press “B” at any time, they will move to the previous Location. (E.g. If the player had previously teleported to Location 2, they will now be teleported to Location 1.

I guess it would be a case of setting up an array of locations and cycling through an index. Just a bit stuck on getting it working!

Any help would be appreciated!

Thanks!

This is perfectly doable.

To have a better idea on how the character could store and sort through the locations → How is this path generated?

This

Just make a BP actor called teleport location, it’s much easier than typing in coords…

1 Like

Hey @ClockworkOcean

Thank you for such a quick response! Really appreciate it.

I’ve had a play around but I still can’t quite get it all to work. (Most likely me being inexperienced and misunderstanding)

Using your blueprint above, I was able to teleport to the first location, but not beyond.

I created a BP Actor, duplicated it a few times and placed them in the locations I want the player to be teleported to.

Here is what I tried previously, maybe you would be able to expand on that? Or if possible, perhaps explain the above in a little more of an idiot-friendly way just in case I missed something :sweat_smile:

Just to reiterate again - I am looking to Teleport between set locations (as marked by my BP Actors), in a chronological order (with “A” as an input). I would also like the ability to Teleport back to the previous location (With “B” as an input)

So I believe I am just looking at some way for the game to track the index of the Teleport Points, +1 when I Teleport to the next location, -1 when I Teleport to the previous location, and Teleport me accordingly.

Please let me know if I’m way off the mark! Thanks so much

First thing, try putting the teleport point about 50-100 units above the ground. The teleport node is a little fussy about collision.

That’s exactly what my code does :wink: Let’s get the A working, then the B will be easy.

1 Like

Hey @ClockworkOcean

Amazingly, moving the BP Actors above the ground slightly has fixed it - lol!! It now works perfectly!

Thank you so much!

For Teleporting to the previous location with “B”, I thought it may have been as simple as swapping out the Increment Integer with a Detrement Integer and linking that to the B Input but it seems to have no pattern at all to the Teleporting - if you could share your solution to that then I will be so grateful!

Thanks!

1 Like

Then it’s

Incidentally ( I’m anticipating the next question… ), if you want to know how to make the teleports happen in a certain order, you can give the locaton BPs IDs

When you put them in the level you set the ID order ( zero upwards ), and the initial collection goes like this

3 Likes

Amazing - works perfectly!

Thank you so much for this, that Hero tag under your name really checks out!

2 Likes

You’re welcome :slight_smile:

I am trying to piece together several of your posts in several discussions :smiley: I am a noob but your clues are helpful even though I can’t quite get this to work. Ultimately, I want the ordered location teleport… I am stuck how you get the ID variable in the array element (blue) to match the array index (green) - I now it’s due to my lack of UE5 understanding!

I did try get the original (unordered) version to work, but I think I haven’t constucted my variables correctly - a vector array wouldnt suffice - do I need a stuct with two arrays for location and rotation?

You have been so helpful and you pop up everytime I search for a teleport setup!

You mean this part?

The blueprint type I’m looping through, has an ID variable. So I can just grab it as I’m going through the loop.

What do you have so far?

1 Like

I think my biggest sticking point is accessing variables from BPs - I did mean the part you highlighted :slight_smile:

I created a TargetPoint BP class, created a integer variable in it called ‘ID’ and set it as public. I could create copies of these TargetPoint BPs and just edited the ID variable (int). I think my trouble is now trying to reference that variable from my BP_FirstPersonCharacter (I’m using the level example from UE5.2.1 - FirstPerson).

I’ve seen videos where people can highlight the BP in the content browser, or scene and then reference that in the blueprint editor, even from another BP. It’s probably something simple but I am a noob and still learning (believe me, it took me a while to get the actor class set - it was only when I went to TargetPosition class did things start improving!)

Also, this is a solved thread and I should probably start a new topic - sorry!

The ‘get actors of class’ is the crucial node, you need to use that. It gets all BPs of that type in the level.

1 Like

I am using “get all actors of class” and I can output a forEach loop with each location, rotation, name but it’s the ID variable in each targetpoint instance I’m struggling to reference.

Your posts have been hugely helpful, I’m just clearly needing to learn a lot more than I already know!

1 Like

Can you show a picture of your code?

I noticed you’re talking about making a target point BP class, whereas I called it ‘teleport location’. Of course this doesn’t matter, but I think your problem maybe that you’re doing this

image

Instead of getting your BP class…

I think I’m trying to run before I can walk! :smiley:

I created TargetPoint instances named TeleportPoint_x and in each of these I change the variable ID default value:

I can actually extract all the info from each “teleportpoint” using this debug code:

which gives me the correct output of each of the teleportpoints:

What I can’t do, is reference the ID variable I have created in those instances:

I have tried “ID”, “teleportpoint”, and everything I can think of!

I really appreciate your time and help with this - as people have often said, you certainly deserve that hero title! In reality, I could explicitly define a small number of locations and rotations manually for my use case - I am interested in this because it makes more sense using your approach.

It’s what I said it was. This

image

Should say ‘teleport point’.

Also, you only need 1. Drag it into the map more than once

The instancing occurs when you drag into the map.

You set ID when you drag them into the map :slight_smile:

1 Like

You are a hero! Thank you so much for helping me out with this! I have it working! You helped me in so many ways and my journey of learning and creativity can continue!

This has been giving me headaches for days - you’ve made me very happy now!

T H A N K Y O U ! ! !

1 Like

:+1: :sunglasses:

1 Like