Can't enable Hit Event on Pawn
I want to receive a Hit Event when my Pawn bumps into another object. I created my Pawn Class in C++ and Subclassed in in Blueprint. It has a StaticMeshComponent as its RootComponent. I overrode (is that a word? :) ) ReceiveHit in C++:
The event never fires. I read that I have to enable "Simulation Generates Hit Events", but the Details Panel in my Blueprint doesn't show it:
![StaticMesh Details Panel]
I also tried binding on the StaticMeshComponents' OnComponentHit Event, but that one doesn't fire either.
Am I missing something? Can I set the "Generates Hit Event" status form C++?
Edit: I'm using Unreal Engine 4.7.1 btw.
Edit 2: eXi, why have you accepted the answer as correct? It provides a workaround, but I refuse to accept this as a permanent solution to the problem! If I think an answer is sufficient, I will happily accept it myself! Unfortunately I don't have the permissions to remove the "Accepted" mark. I was hoping for more suggestions regarding this issue. If there is no way to do this in UE4, please simply tell me or let me file a bug report!
Thanks for your Help!
David : /storage/temp/31628-capture.png
I have found another workaround myself which I'd like to share here. It avoids the inconvenience of a separate collision mesh.
I had a custom C++ Pawn class (AShipPawn) with a static mesh as its root component:
In the Constructor I created a new Static Mesh Subcomponent.
In Blueprint, I subclassed the AShipPawn class and set the Static Mesh and changed several other properties. As shown in the initial post, I was unable to Enable "Simulation Generates Hit Events".
Don't create the UStaticMeshComponent in the C++ class constructor! I simply left the variable with a nullptr value and didn't even set the RootComponent:
Then in Blueprint, I used the UI to create a new UStaticMeshComponent, set all the values and the Mesh and assigned my shiny new UStaticMeshComponent as the RootComponent of the Actor. If the Object is created in Blueprint, I can also set "Simulation Generates Hit Events". Last Problem to solve is that my C++ class needs to manipulate the Mesh during gameplay (AddForce(), AddTorque(), ...), but the variable in C++ is still a nullptr.
The solution is a simple Blueprint Construction Script that sets the Blueprint-Generated component as the value of the C++ variable:
Make sure that you have "Show Inherited Variables" checked in the Blueprint, otherwise you won't be able to see the C++ variable.
This process might seem obvious for experts, but it certainly wasn't for me. I still think this is a bug, but I don't know how to tell the devs...
I hope this helps someone else.
answered Mar 03 '15 at 09:32 AM
Maybe this will help
Added to my class(called Zplane)
**ATestPawn is my class that " destroys" the hit object(collisionComp in my Zplane class)
If you don't add the AddDynamic part to the object you want to be hit, it won't work at all. hope this helps!
Follow this question
Once you sign in you will be able to subscribe for any updates here