The last change to this command used the spawn card for spawning and with reference to the player's foot position (#149). This introduced various issues.
Not every master has a spawn card, which requires constructing one on the fly.
Spawning via the spawn card eventually calls CharacterMaster.Respawn which recalculates the spawning position to be on the ground. That in combination with CharacterBody.footPosition would ensure enemies spawn properly on the ground. For example, an Imp Overlord (as a player) is too tall and the respawn adjustment would fail to find the ground if the spawning was done from its core position. However, this change causes flyers to spawn under the player and into the ground. Other big entities instead force the player to clip into the ground as their colliders overlap. While this overlapping existed with the previous method, due to their relative positions they would just push each other away laterally. The solution is to take the spawning entity's size into account and spawn it far enough so there are no collisions. Flyers also now spawn above the player's head.
A lot of the calculations involved to address the second issue also play into the fact that spawning multiple flyers in the same spot causes them to be flung away. As such, the command had not been very useful to spawn, for example, multiple wisps, at the same time. I have changed the spawning procedure for flyers to spawn them in a ring with a radius big enough to ensure no overlap. This increases with respect to the number of requested spawns.
Another issue with this command irrelevant to the above, is that the character master keeps a reference to its ai components and it has no safeguards for null checking before acting on them. This can cause errors for a braindead entity, so the array is emptied. I figured it was too small of a change to make a whole separate PR for it.
The last change to this command used the spawn card for spawning and with reference to the player's foot position (#149). This introduced various issues.
CharacterMaster.Respawn
which recalculates the spawning position to be on the ground. That in combination withCharacterBody.footPosition
would ensure enemies spawn properly on the ground. For example, an Imp Overlord (as a player) is too tall and the respawn adjustment would fail to find the ground if the spawning was done from its core position. However, this change causes flyers to spawn under the player and into the ground. Other big entities instead force the player to clip into the ground as their colliders overlap. While this overlapping existed with the previous method, due to their relative positions they would just push each other away laterally. The solution is to take the spawning entity's size into account and spawn it far enough so there are no collisions. Flyers also now spawn above the player's head.A lot of the calculations involved to address the second issue also play into the fact that spawning multiple flyers in the same spot causes them to be flung away. As such, the command had not been very useful to spawn, for example, multiple wisps, at the same time. I have changed the spawning procedure for flyers to spawn them in a ring with a radius big enough to ensure no overlap. This increases with respect to the number of requested spawns.
Another issue with this command irrelevant to the above, is that the character master keeps a reference to its ai components and it has no safeguards for null checking before acting on them. This can cause errors for a braindead entity, so the array is emptied. I figured it was too small of a change to make a whole separate PR for it.