From what I can tell, the capsule component on ACharacter is centered at the origin. This means that the transform of a character is their center of mass rather than their feet.
This creates a challenge when implementing generic spawning. With how the transform is handled on characters, it means that the spawn transform needs to be above the floor based on the height of the character (the half height, to be exact). Ignoring for a moment that this is a bad idea, with characters of different size, this wouldn’t work anyway.
The only “correct” way I can see to do this would be to put the spawn point on the ground, grab the half height of the character from the CDO, and use that as an offset to the spawn location. This has a couple problems.
First, it means you need to know what you’re type of object you’re spawning. You have to know what you’re spawning. You cannot generically spawn an Actor of class AActor. You have to either require ACharacter or a derived type or you have to cast your class type before spawning.
Second, it means that you are required to have a fully loaded class asset when choosing to spawn in your logic. Yes, for the simple case this is usually fine but in a more abstracted system, the logic that triggers a spawn (and decides where to spawn) might be far removed from the logic that does the actual spawning. The dependency on data in the CDO adds a requirement that the data be loaded ahead of time which is not always ideal.
In a perfect world, I’d love to be able to change the origin to be at the feet but I don’t believe that’s possible without creating engine divergences and possibly fighting with assumptions the engine makes.
Is anyone aware of an alternative here?