Announcement

Collapse
No announcement yet.

How to bind a function to OnActorHit?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to bind a function to OnActorHit?

    I'm trying to define a function that will be called when my actor collides with another actor. My code is like this
    In Character constructor:
    Code:
    BindDynamic(OnActorHit, OnMyActorHit);
    OnMyActorHit definition:
    Code:
    void OnMyActorHit(class AActor * SelfActor, class AActor * OtherActor, FVector NormalImpulse, struct FHitResult Hit);
    When I try to compile it says __Internal_BindDynamic is undefined
    I also have Delegate.h included in my cpp file
    I'm not sure if this is the right way to do this. Any suggestions?
    Last edited by conda; 04-04-2014, 09:47 PM.

    #2
    Hi Conda,

    The first argument to BindDynamic is the object you want to bind on, try using it like this:

    Code:
    OnActorHit.BindDynamic(this, &UYourClassName::OnMyActorHit);
    Cheers,
    Michael Noland

    Comment


      #3
      Originally posted by Michael Noland View Post
      Hi Conda,

      The first argument to BindDynamic is the object you want to bind on, try using it like this:

      Code:
      OnActorHit.BindDynamic(this, &UYourClassName::OnMyActorHit);
      Cheers,
      Michael Noland
      Thanks. I tried that but an error is still being shown: FActorHitSignature has no member __Internal_BindDynamic

      Comment


        #4
        I looked into this briefly but couldn't figure it out either nor is this topic covered on the Wiki

        For now you could modify the source to call the subclass til we learn the 'proper' way this is handled. Luckily, I do not need this event myself atm
        Godz for UT '99 / UT 2003

        Comment


          #5
          Originally posted by sandboxgod View Post
          I looked into this briefly but couldn't figure it out either nor is this topic covered on the Wiki

          For now you could modify the source to call the subclass til we learn the 'proper' way this is handled. Luckily, I do not need this event myself atm
          Yea that works for the moment but it will get tedious when I want to set each event function for multiple character so I'm gonna wait for an official answer. Thanks anyway.

          Comment


            #6
            Code:
            TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AHidingSpot::ActorEntersTrigger);
            TriggerBox->OnComponentEndOverlap.AddDynamic(this, &AHidingSpot::ActorLeavesTrigger);
            That is how i used it. OnActorHit delegate is also dynamic multicast, so i guess it should work.
            Alone: The Untold - a story driven horror game

            Comment


              #7
              Thanks BiggestSmile, that does indeed work

              Code:
              OnActorHit.AddDynamic(this, &AMyCharacter::OnMyActorHit);
              AMyCharacter::OnMyActorHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
              Godz for UT '99 / UT 2003

              Comment

              Working...
              X