OnActorHit, delegate how do they work?


I have a very simple character class in my project, the goal is to make my character bounce when it hits stuff, in a very non-physical manner. So I thought that I could use OnActorHit and then give my character a push when hitting stuff. So I probably want some data about the collision, e.g. a normal and the force of the collision. But I can’t figure out how to write the code and I can’t for the life of me find any examples, tutorials or similar on how to do it. I’m using Unreal Engine 4.7.2. So I would be very happy if someone could give me a small example how to setup a delegate for OnActorHit (if that is the most suitable functions to use in my case).

Hi look at the answers at those links:

They have some insightful information that migth give you a starting point.

As for the the event you can use any collision related events, like Overlap, in your Characters blueprint right click, add the event and use it as the starting event described in the links above.

As for C++ only look the the documentation here:

void UYourActorComponent::InitializeComponent()
    FScriptDelegate Delegate;
    Delegate.BindUFunction(this, "OnActorBump");

class UYourActorComponent : public UActorComponent
    void OnActorBump(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit);

void UYourActorComponent::OnActorBump(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
    // Handle....