As the title suggests, when I cut the tree instead of spawning the trunk and tree top to make the tree fall at the original tree location, instead it spawns at 0,0,0.
That’s odd.
Maybe it’s because of getting classes this way. I generally declare TSubclassOf<> and set the class reference manually because I create blueprints based on c++ classes for customization purposes. And since here the newly created UClass is probably a pointer, it calls the overloaded function with pointers.
What is the actor classes ESpawnActorCollisionHandlingMethod ? The default behaviour of SpawnActor is to use the actors setting.
I would debug this by setting a breakpoint and then stepping in following the value of transform until the actor spawns and its root component transform is set. It’s not far I don’t think.
Ok, I set the `ESpawnActorCollisionHandlingMethod::AlwaysSpawn to ignore collision thinking that this would help but it did not. I watched the transform on spawn in debug and even though it is passed correctly from the FTransform variable it continues to spawn at 0,0,0.
Also tried AdjustIfPossibleButDontSpawnIfColliding and it still spawns at 0,0,0, so it’s not a collision problem in my undestanding.
@zos Still not working. I don’t know why instead of setting the location to the referenced one it sets it to the default 0,0,0 . Still trying different possible solutions in order to figure out why this is happening.
I’d keep trying with the debugger. Follow the transform value until it gets set on the root component. At some point it has to change from your setting to zero. It does show zero vector when you play-in-editor and look at the actor in the outliner right?
Oh, I skipped a very important part of your reply. The root component. The root component does take the correct transform but the static mesh does not.
So I created the ATreePart [Static Mesh Actor] class that was either the trunk or the TreeTop parts of the tree. Mistakenly I created a Default subobject inside the ATreePart and assigned there my static mesh [in the constructor, of course, attached to the root component].
The problem that arises was that because it is a StaticMeshActor the engine didn’t track secondary static meshes or some sort of that, and it did not assign the aforementioned transform to the created static mesh as a subobject but only applied the transform to its original static mesh.
Now that I removed the secondary static mesh from ATreePart, upon cutting the tree, the two parts, trunk and tree top, spawn at the passed transform.
Thank you all for the help and guidance to the solution, as well as for your time spent with my issue.