Need help with Referencing other BP's and Relative Location

Hello!

I’m having a slight problem, and I feel like there’s something I’m not quite grasping. Im setting up a system to generate modular rooms. I’m trying to use a component to judge how far the next room needs to spawn away from the current room in order to not clip using relative location. However, I feel like im not referencing BP’s correctly in order to grab information from them.

Basically, I want to grab another BP’s component relative location, but i’m getting errors and I think im doing something wrong.

ProcRoom:

Viewport (Highlighted arrow is spawn point for room):

Error:

Looks like your Room to Spawn variable is not initialized properly by the Switch and is Null. Where are Proc Room 1 and Proc Room 2 coming from?

I’ve tried it while initializing it and it still gives the same error as well. ProcRoom1 & ProcRoom2 are the actor BP’s im attempting to spawn when triggering the volume.

I’ve changed it to show the initialization and with no switch involved, but the same errors are given.

https://i.imgur.com/3RgzLbb.png

OK but then your logic is not correct. If you are trying to Spawn actors of a certain class, first you call the Spawn node to spawn them (place them in the level), then access their properties. Before you spawn them, they don’t exist in the level, so you will not be able to get their location.

So:

  1. Decide which class of BP to Spawn

  2. Spawn an actor of that class

  3. With the reference to the spawn actor, access its properties

In this way it should work as expected.

Yeah I see what you mean, but is there a way to grab a component’s relative location without spawning the actor first? That’s mainly what I’m attempting to do. I don’t see why I would need to spawn an actor to grab one of it’s components relative location.

EDIT: To simply what I mean, here’s an example of spawning Proc room 1 with the Arrow component’s relative location inputted manually (500, 0, 0), and it works like it should. However, I want to be able to use multiple proc rooms by grabbing the Arrow component’s relative location for each one.

You can try with Get Class Defaults, but I am not sure it will work in your case. Probably you need to edit the Construction Script to extract the relative location you need and store it in another variable you can access through the defaults. Give it a try.

Or you can spawn your actors as invisible on Begin Play, get the values you need out of them, then Destroy them. Just a workaround though.