Unable to correctly get a reference to an actor

Hi all, so I’m attempting to get a reference to three actors, (each has their own object reference variable) and thus get their location.

However when the print node prints their individual locations, all three of them print (0,0,0). This leads me to believe that I’m referencing it wrong. This is my simple script:

As I said, the print string prints (0,0,0) so I’m referencing it wrong.

A bit more info:

  • The actors ( I’m trying to get their location) are spawned after the player starts playing the game, rather: throughout it.
  • This actor (their BP is shown right here) is created after all three of the other actors are created

Here is my variable defaults/settings for the object reference variable

Thanks a lot!

Well where do you reference them?

You want to water your flowers (-> get the vector) but right now you have an empty bucket (-> a variable) and try to water your flowers with it (-> get the vector from an empty variable)

You either have to store those variables somewhere else and let the actors save the reference there themselfs (which doesn’t work here because it hasn’t spawned when the actors are created) or you can use “Get All Actors of Class” if there is only one of each actor at any given time. This will provide you with an array. Since you always only have one just get 0 and use that instead of the variable.

I hope this helps.

Cheers

Thank you! This is perfect.
For some reason though my triangle seems to be offset:

Do you think you can help me figure out why this is?

Here is my short blueprint script:

Sorry. I got no engine nearby (and by that I mean I have no computer available on which I can run it or which has a good enough internet connection to download it within the next few days) and never worked with mesh generation so far so I don’t know where your code goes wrong.

Have you tried placing it manually into the spot (simulate and then change the location and rotation) to see if it has the correct size. Maybe your mesh component is a bit off or the generator only generates a mesh but not with the exact location (after all you only provide a triangle and not the locations anymore).

Just random guesses though. As I said. I never worked with this so far.

Cheers

I’ve fixed it. Turns out that I was offsetting it slightly by having weird numbers in the spawn transform. Many thanks for your help! Really appreciate it :smiley:

You cant store them and load the game. A stored reference will spawn once and then the next item in the list will indeed spawn with correct appearing logic. But that object is invalid and came from an invalid reference so it cant be referenced by the items. Aka if you set a slot to disabled then spawn on object from index 2 of a list after loading it will spawn it and enable the slot but the slot is actually empty for functions and full at the same time. Aka if you have logic that say removes text from something based on a click event or drop event it will fire as if an item is in there and remove or add all the stuff as long as the stuff is not referencing itself because itself is invalid. How is it possible that unreal engine cant save variables yet people have claimed to have made and launched games from it? i can say with 100% fact no game has ever been produced and packaged from it. The act of packaging breaks half the references 100% of the time randomly based nonsense blank lists which are filled from a save list. so one can assume you can never put them in a list and hope it works but i honestly doubt that.