Spawn and set GeometryCollection initialization fields at runtime

Here is my component view:

The child actor above is just a FS_AnchorField_Generic.

I’m calling this simple event in my construction script:

If I place the actor in the level, it works fine. However if I try to spawn the actor during play, the anchor field is not set and the GeometryCollection falls to the ground.

Any ideas?

4 Likes

Did you ever solve this? I believe initialization fields must be set in the constructor, but I’m having the same problem.

2 Likes

Having the same issue lol we must seek an expert

3 Likes

I suspect it cannot be done in Blueprints, likely due to interactions between Chaos and other actors. I think I saw a post about somebody doing it in C++, but now I cannot find it!

it certainly can be done in BP but i think the idea seems like it didn’t cross the mind of whoever is in charge of this side of the engine

Let me rephrase that. I don’t think it can currently be done in blueprints without some further changes from epic

Apparently, it can be done in C++. I think I understand what this person is doing except for the ‘header file’ part.

Dynamic Anchor Fields? - Chaos : unrealengine (reddit.com)

1 Like

Hi there, I don’t have a solution sorry but I would like to try what you have here in the construction script! Im stuck at the first part though and I can’t find the ‘clear initialization Fields’ node or the the ‘Add Initialization Field’ node. All help would be appreciated!
Cheers

Did you ever figure this out?

OK so for my project what i did is
Add geometry collection component
set the mesh
then disable physics.
add a box collision around the GC and when overlapped it enables physics.
now this might not work if you want to partially destroy a mesh.
but for destroying a whole mesh it’s flawless.

Anyone know if the Initialization nodes (Add Initialization Field, clear Initialization Fields) have been removed in 5.1.1? I don’t see them.

1 Like

Try this :

1 Like

This works for me when the blueprint is placed in the world, but does not work when that same blueprint is spawned into the world.

Have you had any luck making anchor fields work within spawned blueprints?

So, I’ve been having the same issue. Anchors work if the BP Is already in the level, but doesn’t when I try to spawn. I was able to get it to work though. Make sure Physics is turned off on the GC in your BP. Then add a delay in the BeginPlay node and Set Simulate Physics to true. This worked for me, not sure if it will for anybody else.

8 Likes

This worked for me, thanks! I didn’t even need to set a delay, just set the physics flag after creating the anchor.

1 Like

So spawning it at actual runtime for example if you want to respawn it, so well after beginplay and then attaching the anchor field is not possible right now? Or is there another way to respawn or reset an existing collection?

1 Like

So thanks to this hint I got it working for myself. I have BPs of GCs that I wanted to be able to reuse freely. I created box collisions in my BP that serve as points to spawn in anchors points. In the construction script, I loop over each geometry collection component and turn off the physics, then on begin play I loop over each box trigger, spawn an anchor point of the same size, add those new anchors to each GC, and reenable the physics for each GC.

1 Like

Thanks folks, this solved it for me too, very helpful!

Just a heads up for anybody still messing around with this: For me it wasn’t enough to disable physics in the Construction Script. I had to disable it on the Geometry Collection itself and then enable it later in the blueprint. After that, Luna2442’s post worked.

My Editor freezes when turnin simulation back on ((