x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Unreal crash while Spawning actor c++

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.

 void AObstacle::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
 {
     UE_LOG(LogTemp, Warning, TEXT("Overlapped"))
 
     SpawnLocation.X = this->GetActorLocation().X + 5000;
     SpawnLocation.Y = this->GetActorLocation().Y; 
     SpawnLocation.Z = this->GetActorLocation().Z;
 
     SpawnRotation = FRotator(0.f, 0.f, 0.f);
 
     if (ObstacleBP == NULL) { UE_LOG(LogTemp, Warning, TEXT("Obstacle is NULL")) return; }
     GetWorld()->SpawnActor<AObstacle>(ObstacleBP, SpawnLocation, SpawnRotation);
 
     this->SetLifeSpan(3.f);
 }

i tried some similar thing before and i assume its becuz collision stuff. so here is a photo of Obstacle's mesh and colliders. alt text here is where the obstacle should be Spawned(this is Floor which contains Some Collision to prevent the Player from falling. alt text

thank you x_X.

Product Version: UE 4.21
Tags:
2019-05-20-1.png (539.9 kB)
2019-05-20-2.png (546.7 kB)
more ▼

asked May 20 '19 at 11:08 AM in C++ Programming

avatar image

Shayan.ebz99
13 3 4

avatar image phil_me_up May 20 '19 at 02:04 PM

Have you got the crash logs? That'll help identify where the problem lies.

avatar image Shayan.ebz99 May 21 '19 at 05:29 PM

Stack overflow - code c00000fd (first/second chance not available)

PhysX3PROFILE_x64!physx::Sq::AABBTreeOverlap::operator()() [d:\build++ue4\sync\engine\source\thirdparty\physx3\physx_3.4\source\scenequery\src\sqaabbtreequery.h:74] PhysX3PROFILE_x64!physx::Sq::AABBPruner::overlap() [d:\build++ue4\sync\engine\source\thirdparty\physx3\physx_3.4\source\scenequery\src\sqaabbpruner.cpp:287] PhysX3PROFILE_x64!physx::NpSceneQueries::multiQuery() [d:\build++ue4\sync\engine\source\thirdparty\physx3\physx_3.4\source\physx\src\npscenequeries.cpp:791] PhysX3PROFILE_x64!physx::NpSceneQueries::overlap() [d:\build++ue4\sync\engine\source\thirdparty\physx3\physx_3.4\source\physx\src\npscenequeries.cpp:104] UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_Engine UE4Editor_RollerBall_587!AObstacle::OnOverlapBegin() [d:\unreaal projects\rollerball\source\rollerball\obstacle.cpp:65] UE4Editor_RollerBall_587!AObstacle::execOnOverlapBegin() [d:\unreaal projects\rollerball\source\rollerball\obstacle.h:12] UE4Editor_CoreUObject UE4Editor_CoreUObject

here is the error log which appears when editor crashs

avatar image HOUmmel May 20 '19 at 02:44 PM

I guess it will spawn Actors like crazy when it overlaps. Try to add some check that this don't happen.

avatar image Shayan.ebz99 May 21 '19 at 02:52 PM

by the word crazy, it means? do you know any way to solve this? i guess its ue4 bug

avatar image Lobotomiac May 21 '19 at 07:01 PM

Try

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 :)

avatar image Shayan.ebz99 May 21 '19 at 07:07 PM

hey, thanks but i kinda figured the problem, as i said in main question, its all about collisions. (:

avatar image Lobotomiac May 21 '19 at 07:12 PM

Coolzies. :) mark it as answered to help others :)

avatar image Shayan.ebz99 May 21 '19 at 07:18 PM

sure, thanks (:

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.alt text

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

2019-05-21-3.png (530.2 kB)
more ▼

answered May 21 '19 at 07:17 PM

avatar image

Shayan.ebz99
13 3 4

avatar image Lobotomiac May 21 '19 at 07:20 PM

good to have in mind :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question