How to detect collisions of a pawn, where the rootcomponent is empty?

Hello,

im currently extending the Flying C++ example and I am currently working on my Pawn.
However for some specific reasons, my plane is not located at the root, but is a child of the root. (see image)

Now I have some trouble detecting collisions. My static mesh(PlaneMesh) already has a collider.
If i turn physics on for my PlaneMesh, collisions are detected, but my plane falls right from the sky …but without my Root. And my PlaneMesh is not affected anymore by moving the root.

Then I tried replacing the Root with a UBoxComponent to activate Physics on the Box and to detect collisions. But on this version my whole UE4 crashes after ~4 sec of playing.
On this setting, I also get this warning:

PIE:Warning: Warning Invalid Simulate
Options: Body
(MyPawn_C_2.Root0) is set to
simulate physics but Collision Enabled
is incompatible

So here are my questions:

  • is there another way to detect collisions? (beside having “simulate physics” activated)
  • what is the proper way if I want collision detection only on a subcomponent, but not the root of the pawn?

Thanks for the help :slight_smile:
Greetings.

If I’m not mistaken Simulate Physics treats all elements independently, hence why the plane falls on it’s own. What are your collision settings on the plane and how are you testing your collision?

Here is the C++ Code where I build my components together.
80111-
Here is my Blueprint which inherits from the C++ Code and the collision settings.
(Here I only activated “Simulate physics” and “Simulation Generates Hit Events” on the root component)

Ok, I found out something weird.
My current setting works now and my plane doesn’t fly through my landscape anymore.

However my spawn point is at the border of my landscape and my plane is falling down (due to gravitiy) and is thus placed outside of my landscape. Then after a certain height is achieved (under landscape) the crash happens.

If I however fly over my landscape or have at least a certain height then everything is fine.

Is there another way to decect collisions without having to simulate physics?

Edit:The prints in the blueprints are not happening. (I think im logging them wrong.)

Here as well my Hit Method from my c++. I do not see logs from this function either…

Your collision is set to OverlapAllDynamic so it won’t generate collision, just overlap events. Try changing it to Pawn or BlockAll.

Alternatively you can try locking your Z coord under Physics > Constraints > Lock Position. This will stop the object moving over Z axis (up/down), but that might not be what you want, depending on the situation.

When you change collision preset, disable Simulate Physics

thanks for the quick help, works for me now.

you’re awesome :slight_smile:

I have one last question though:

If I only set the collision to BlockAll it works if I do this on the root as well as on the PlaneMesh.

However if I enable Simulate Physics on the root now as well, the game crashes instantily. Do you have any clue why?

Nope, but if you upload logs it might be helpful

[2016.02.26-22.08.34:300][454]LogBlueprintUserMessages: Late PlayInEditor Detection: Level ‘/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel’ has LevelScriptBlueprint ‘/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel.FlyingExampleMap’ with GeneratedClass ‘/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap_C’ with ClassGeneratedBy ‘/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel.FlyingExampleMap’
[2016.02.26-22.08.35:554][454]LogCrashTracker:

[2016.02.26-22.08.35:558][454]LogCrashTracker:

[2016.02.26-22.08.35:558][454]LogWindows:Error: === Critical error: ===
Fatal error!

[2016.02.26-22.08.35:582][454]LogExit: Executing StaticShutdownAfterError
[2016.02.26-22.08.35:584][454]LogPhysics:Warning: PHYSX: …\PhysX\src\NpScene.cpp (2946) 8 : PxScene::unlockWrite() called without matching call to PxScene::lockWrite(), behaviour will be undefined.
[2016.02.26-22.08.35:584][454]LogPhysics:Warning: PHYSX: …\PhysX\src\NpScene.cpp (2946) 8 : PxScene::unlockWrite() called without matching call to PxScene::lockWrite(), behaviour will be undefined.
[2016.02.26-22.08.35:584][454]LogPhysics:Warning: PHYSX: …\PhysX\src\NpScene.cpp (2946) 8 : PxScene::unlockWrite() called without matching call to PxScene::lockWrite(), behaviour will be undefined.
[2016.02.26-22.08.35:584][454]LogPhysics:Warning: PHYSX: …\PhysX\src\NpScene.cpp (2946) 8 : PxScene::unlockWrite() called without matching call to PxScene::lockWrite(), behaviour will be undefined.
[2016.02.26-22.08.35:584][454]LogWindows: FPlatformMisc::RequestExit(1)
[2016.02.26-22.08.35:584][454]Log file closed, 02/26/16 23:08:35

Hi, solution can be found at posted question.

Simple answer: just turning collisions on is not enough, you have to specify the Collision Presets. This configure against which actors a collision creates an event.

Hi, I just wanted to notify you, that I fixed this crash error some time ago.

It turned out that my PlayerController accessed the pawn without checking if the possessed pawn is not null. On Unity im used to have this kind of error in my console. Here however the whole client crashes. Interesting :stuck_out_tongue:

Thanks again for your help.