Unable to set actor variable in blueprint outside instance

Hello,

I’m trying to make a gem teleport my character to a waypoint, but unless I set the waypoint actor on the instance, it just errors. I can’t set the default in blueprint either.
How could I resolve this?

I’m also likely to add more waypoints along the way too, so I’m also assuming I’ll need a new waypoint for each one?

Sorry, this is the first project I’m expanding on my own outside a course, so I’m a little like Bambi atm!



If you’re going to have a lot of waypoints, what you could do is use a boolean in the waypoint ‘used’.

When a waypoint is used, just set the boolean.

When the gem wants to teleport the player, use ‘get all actors of class’ and find one with ‘used = false’.

Something like that.

Either that, or maybe you can just set the waypoint on the gem when you put it in the level. Unless you spawning them dynamically.

Hey there @JodieKitten! Welcome to the community! So defaults can be set for anything that isn’t referencing another instanced actor. In this case, you want to set your waypoints that are in the scene as the defaults, however this blueprint has no idea a scene exists until it’s in it. There are a number of ways you can set the waypoints as this object is generated that would also make it futureproof.

Generally it’s advised if you’re going to have only one gem active at a time, you can set the reference when the level starts by using Get Actor of Class. If there’s going to multiple, you can Get Actors of Class and then run a loop over them for criteria like Clockwork mentioned.

How do you want your gems to function? Just as a level change or in-level teleporter?

Hello :slight_smile:

So I haven’t learnt how to change between levels, so I figured I’ll make one long level and have a gem in each section that will teleport the player to the next section.

No worries! If you’d like you can place an instance of your manager in the level and set the waypoint references directly in that case if you’d prefer. It’s definitely simpler but more work for you in the future!

Or if you’d prefer I can get you resources on levels. Really however you want to go about it. Just the defaults themselves can’t be set to existing things in scene unless it’s already an instance itself.

Hello :slight_smile:

I’ll definitely give that a try! Sounds simple enough even for me haha.
This sounds like a silly question, but how will the individual waypoint know it’s been used?

Another approach is to make the waypoint and the gem one actor:

Player hits the gem and gets teleported to the waypoint arrow; this way we need no (hard) references whatsoever and no script in the player - it’s going to be a busy class anyway.

You can manipulate the location of the gem / waypoint arrow / actor freely. You can even set world transforms to absolute if that’s more convenient.

Here’s my attempt… :sweat_smile:

Although it still came up with “accessed none trying to read waypointref node”

Hello :slight_smile:

This makes sense, the gem isn’t being used for anything else. I’ll give this a go too!

Thank you :blush:

Awesome, thank you! :blush:

You didn’t use the output :wink:

image

Of course I didn’t, what a noob :smiling_face_with_tear:

Thank you :blush:

It could also work in case you needed a non-linear level design where many gems lead to one waypoint - a hub of sorts:

And, finally, nothing stops you from having many waypoints and many gems in a single actor - interlinked any way you need. Perhaps the teleport locations are random (pokes @Zof)

Think of the waypoint gem actor as a manager blueprint that controls where the player goes. How to go about it depends on the scope, ofc.

Good luck!


On the other hand:

unless I set the waypoint actor on the instance

This is one of the better methods actually.

It never occurred to me that you could do that!
Your first suggestion worked perfectly for me and I’m definitely keeping this one in mind for future use, you’ve definitely given me some ideas haha

Thank you so much for your help :smile:

2 Likes

So I’m completely unable to start a new topic for some reason, so I’ll add it to this post in the hopes it get seen :sweat_smile: :

My game uses a timer handle to track how long the player takes to complete the game. I’d like it if I could save the end time and use it as a “best score” that is displayed and updated should the player beat it, is this something I could do?

Here’s the HUD display and graph (I followed a YouTube tutorial to get this game going, so any suggestions to improve/change things would be appreciated!)

Thank you! :blush:


You’re reinventing the wheel (of time), hehe. A timer already counts time!

Essentially, you run the timer indefinitely and ask it how much time has gone by. Also:

The timer can do other useful stuff!


Some other, totally optional, notes:

  • look into timespan and date time - the engine already handles a lot of the stuff you need:

  • you can use a single text block and push in pre-formatted text:

Oh wow, yeah that’s a much more logical way of doing things, thank you!

How would I go about saving a best score and having it load up and update when it’s been beaten on each game? Sorry, so many questions :sweat_smile: I really appreciate your help!

Save Games

  • you create a save game object
  • put desired variables inside
  • save object to disk using a slot name
  • load from disk using a slot name

Also YT is chuck full of save game tuts. Knowing the right keyword is half the battle - Save Game

Yeah I had a look before but kept getting lost as I was trying to save a timer handle itself as a variable :sweat_smile: but I should be able to follow things better now I have a new way of setting a timer!

Thank you, again! :blush:

1 Like

Never tried saving a timer handle. Never occured to me I could.