hi everyone, there is a problem that i couldn’t solve for days, HELP! i am trying to Spawn an Actor to the world and when i spawn the actor while game is running Unreal crashes. to be specific, i when my player overlaps a BoxComponent i want to spawn an Actor. let’s call it obstacle. here is the code for spawning.
if (Obstacle)
{
GetWorld()->SpawnActor(ObstacleBP, SpawnLocation, SpawnRotation);
}
Instead of just spawning it just for a good measure and if that still crashes then you know to look somewhere else.
Start your UE editor from LocalWindowsDebugger in your IDE to catch the exact thing that triggers your crash.
By crazy I believe he meant that you would be spawning obstacles constantly just popping around but the function is OnOverlapBegin so I think that’s ok since after the initial overlap it doesn’t fire again until you end the overlap and start it again.
And a tip - you can use if (!Obstacle) for a nicer looking code
i am pretty sure that this crash does not relate on my code cuz i attached debugger to the editor and when ue4 crashes there is nothing to do with the code, debugger shows nothing wrong about codes. so i was thinking to change the collision setting. i set the collision of where the obstacle will spawn, and it works.
i literally have no idea why it happens and is it a bug or nah! but it works fine, if you have spawn actor problems, and ur sure there is nothing to do with yr code, without wasting seconds change the collision settings.
when my obstacle’s box component, overlapped by the floor’s box component, becuz of collision stuff of floor, box components of obstacle and floor cuzed the crash O_o