Why is OnActorHit not calling my function?
I have looked at all the most common answers of how to setup to use OnActorHit and tried all of them. I can't seem to get OnActorHit to fire off correctly. I don't get any errors with adding a delegate through the .Add function or using the .AddDynamic function. However, I have been following this tutorial where he uses Event Begin Overlap in a Blueprint and set the Collision Preset to Trigger. I was able to replicate that functionality in C++. However, I decided I want to use OnActorHit instead of overlapping. I can't seem to get OnActorHit to work but I can get OnActorBeginOverlap. Does anyone know enough about OnActorHit as to why this happens? Here is my code below that I have tried for attempting to use OnActorHit.
My Hit Function:
Header file declaration:
I tried the Add Dynamic function too, but couldn't get it too work
asked Nov 11 '15 at 04:11 AM in C++ Programming
The collision is likely set to
Here is a link to ECollisionEnabled::Type
Either that or you may not have your collision response setup correctly. Here is a link to that: Collision Response Reference.
answered Nov 11 '15 at 02:37 PM
Ok then i repost it, you said overlap worked for you so i was scared that i might be wrong and deleted my anwser, sorry:
Don't bind in constructor, what you actully did is binding of class default object (CDO) to event. Everything you do in constructor in UObject based class is used exclusivly to create master copy of object of specific class (previuesly mentioned CDO), thats why if you do something wrong in constructor it crashes engine on start when CDO is created, not where object is spawned. Insted of constructor use BeginPlay() event (or PostInitProperties() in non-Actor UObjects), you are 100% sure at that point that your actor is ready to go. In constructor you only set default varables and setup components, everything related to your class not future object that gonna be created from it.
Follow this question
Once you sign in you will be able to subscribe for any updates here