0

I have an EnemySpawner Blueprint Class that does: enter image description here

EnemySpawner has a Spline Component named "Path" which the Spawned Enemy must follow. For it, Enemy's Blueprint has another Spline Component named "Enemy Path" that must be initialized by the Enemy Spawner at the moment of the creation, as does in the screenshot above.

But, in my Enemy, if I try to access to "EnemyPath", I get the following error:

Blueprint Runtime Error: Accessed None trying to read property PathActor from function: 'ExecuteUbergraph_Enemy' from node: DestroyActor in graph: EventGraph in object: Enemy with description: Accessed None trying to read property PathActor

So, in other words, Null Pointer Exception.

If, for example, in the Enemy's Blueprint I do (with testing purposes): enter image description here The Actor Owner of the Spline Component isn't destroyed.

Even if I try to assign all the Owner actor, not only the Spline Component, it doesn't work either.

I've also tried to print something in screen after the "SpawnActor Enemy" node of EnemySpawner and in the "Event BeginPlay" node of Enemy, and I've checked that obviously the print in EnemySpawner happens first, so the only problem is that the variable isn't really assigned.

The last thing I've tried is to destroy the Spline's Owner right after the "Set" node, directly in EnemySpawner blueprint, by getting it from the Spawned enemy, and to my surprise, it's destroyed!

So, some idea about what's the properly way of doing this?

Maximetinu
  • 140
  • 1
  • 11

2 Answers2

1

You can set any variable in a BP actor with an "Expose on Spawn" flag (in the details panel when the variable is selected in the BP editor) which will add a pin for a value to pass into it when using the SpawnActorFromClass node. Make sure you set the variable(s) "Editable" as well.

0

I think maybe we are doing this wrong.

In straight up C++ you create a class, create the variables, modify the variables by creating a function & passing by ref.

I think that if the Blueprint is a class ( which it is), and if the variable is a variable (which it is), you can't really expect to assign a value to it without calling a function that does it... Then again for all i know maybe the engine does do it for you...