Using custom pool system to respawn character

bitmore

Member
Hi,
I'm working with UCC + UIS + BehaviorDesigner, and using a pool system and spawner to respawn AI enemies.
Not using CharacterRespawner.
I call characterLocomotion.ResetCharacter() before the dead enemy was recycled.

The issue is when the recycled dead enemies were respawned in the scene, they just stand there and idle forever, the BD tree shows they can't patrol the waypoints and can't see the player even the player is standing right in front of them.

What should I do if I want to use my own pool system instead of UCC's ObjectPool? Any suggestions would be much appreciated.
 
The ResetCharacter method only resets the CharacterLocomotion component, not BD. You have to restart / re-initialize BD manually upon respawn. The internal use of the ObjectPool cannot be replaced.
 
Fix this issue by executing the OnRespawn event after the character was re-activated. I don't know the details but I found that the event can only be executed on the character that died once or more, or there will be errors. so I add a charactorLocomotion.Alive check to make sure the re-active character is the one that is already dead and has been despawned.

C#:
spawnedCombatant = pool.SpawnGO(spawnablePrefab, spawnLocation.SpawnPosition, spawnLocation.SpawnRotation, null);
var characterLocomotion = spawnedCombatant.GetComponent<UltimateCharacterLocomotion>();
if(characterLocomotion != null && !characterLocomotion.Alive){
    EventHandler.ExecuteEvent(spawnedCombatant, "OnRespawn");
    EventHandler.ExecuteEvent(spawnedCombatant, "OnCharacterImmediateTransformChange", true);
}
 
Top