Essentially my goal is to move/bend a mesh of a tree, especially the branches, when the tree hits the ground.
Therefore i want to make kind of a physical skeleton of the tree. But as the trees are generated procedurally, the skeleton needs to be generated procedurally too. So my plan was to spawn a bunch of cylinders, rotate and scale them according to the form of the tree, and connect them with PhysicsConstraintComponents. Now comes the confusing part: In a preview version of the engine, the cylinders spawned and connected at runtime perfectly well (although the physicsconstraints didn’t really lock when i set their limits to locked).
Now, in the release version, the “SetConstraintComponents->…” funcion of the PhysicsConstraintComponent doesn’t work anymore in my case, so the cylinders don’t connect and when i stop the game, i get the warning
Constraint in '/Game/UEDPIE_0_level_1.level_1:PersistentLevel.BP_TreeDummyCylinder_C_18.PhysicsConstraintComponent_0' attempting to create a joint between objects that are both static. No joint created.
But when i check all kinds of functions of the cylinders to set and check the mobilty, they always say that the cylinders are movable and not static. I also tried putting the “SetConstraintComponents” function into the tick function in case the game doesn’t register them as movable in code in the constructor and beginPlay yet. But that didn’t work either.
Another problem that confuses me:
I spawn a cylinder as a blueprint that contains a cylinder mesh. I also made a c++ script “TreeDummyCylinder” as the Parent Class of the blueprint, and i spawn it as follows
ATreeDummyCylinder* NewCylinder = GetWorld()->SpawnActor<ATreeDummyCylinder>(CylinderBlueprint, Position, Rotation, SpawnParams);
Somehow the function “SetSimulatePhysics” doesn’t work anymore (it worked in a preview version of UE5) and the only way i can enable/ disable physics is via the blueprint. The reason i’m telling you this is, or the reason because i turned off physics for the cylinders in the first place is, because when physics are enabled, the “SetActorScale3D” function does’t work. But when i disable SimulatePhysics in the blueprint, the “SetActorScale3D” function works.
So this is really messed up. So my questions are:
-why are the cylinder objects registered as “static”? (or is that just a but or something from the physics constraint?)
-why is SetSimulatePhysics not working?
-why is the SetActorScale3D not working when physics are enabled?
or alternative question:
-is there another way to procedurally generate a physical skeleton?