I’m currently making a class that spawns NPCs. The NPCs do spawn correctly at the specified Location
and Rotation
, but I’m facing issues with their collision and gravity behavior:
- Collision Issue: The spawned NPCs don’t seem to have proper collision detection with other objects in the scene. They pass through the player character instead of colliding with them.
- Gravity Issue: Additionally, the NPCs don’t fall due to gravity. They remain suspended in mid-air after spawning.
Here’s a snippet of my spawning function for reference:
AALSCharacter* ANPCManager::SpawnNPC(FVector Location, FRotator Rotation)
{
if (NPCBlueprintClass && GetWorld())
{
AALSCharacter* NewNPC = GetWorld()->SpawnActor(NPCBlueprintClass, Location, Rotation);
if (NewNPC)
{
HandleNPCSpawn(NewNPC); // Custom function to handle additional setup
return NewNPC;
}
}
return nullptr;
}
Could someone please advise on why the spawned NPCs don’t have proper collision and why they aren’t affected by gravity? when I manually drag an instance of the NPCBlueprint in the level editor it works perfectly fine. Despite attempting to enable collision in C++ for the mesh, the NPCs still pass through objects and don’t fall. Any insights or suggestions on how to ensure proper collision and gravity behavior for dynamically spawned NPCs would be greatly appreciated. Thanks in advance for your help!