UE4 c++ OnComponentOverlap and OnComponentHit syntax

Sdílet
Vložit
  • čas přidán 22. 08. 2024
  • Quick set-up of a basic actor in c++, including the on component overlap event.
    Overlap declaration:
    UFUNCTION()
    void MyOverlapFunction(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
    Hit Declaration:
    UFUNCTION()
    void MyHitFunction(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
    How to bind overlap:
    MyPrimitiveComponent(Point)OnComponentBeginOverlap.AddDynamic(this, &AMyActor::MyFunction);
    How to bind hit:
    MyPrimitiveComponent(Point)OnComponentHit.AddDynamic(this, &AMyActor::MyFunction);
    Note using (Point) as it won't allow greater than or less than signs in description.

Komentáře • 18

  • @ReaverPS
    @ReaverPS Před 8 lety +1

    thanks for the tutorial! I really like how you explain little things like where to quickly find the right signature; definitely would appreciate more ue4 c++ tutorials from you

    • @matthewhennegan839
      @matthewhennegan839  Před 8 lety

      +ReaverPS Thanks! I'll do more if I think of any topics to do them on

  • @circle2867
    @circle2867 Před 7 lety +11

    your computer sounds like a hoover

  • @jamesbarradell1929
    @jamesbarradell1929 Před 4 lety +4

    If you are doing this in a later UE4 don't forget to include #include "Components/SphereComponent.h"

    • @Sweenus987
      @Sweenus987 Před 2 lety

      In a later UE4 I don't even have AddDynmaic anymore, just Add and AddUnique 😢

  • @eraser400
    @eraser400 Před 4 lety +1

    Thanks so much for the help!

  • @jeffbitnias4282
    @jeffbitnias4282 Před 5 lety +1

    Is your computer running Crysis in the background? All jokes aside - great video man! Extremely helpful and to the point!

  • @basedbukkakeman7892
    @basedbukkakeman7892 Před 2 lety

    ARIGATOU SENPAI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ^-^ SUGOI!!!!!!!!!!!!!! ONII CHAN SAMA~~~~~~~~~~~~~~~

  • @ResoImages
    @ResoImages Před 8 lety +3

    handy video so ta. fan noise is a bit nuts haha

    • @matthewhennegan839
      @matthewhennegan839  Před 8 lety +1

      +ResoImages Bah I know, sorry for that. Glad you found the video helpful though.

  • @linuxusergd
    @linuxusergd Před 5 lety +1

    Can you link to the .cpp and the .h file in the description please?

  • @DFILL450
    @DFILL450 Před 7 lety

    Have you had any issues with OnComponentEndOverlap? I can't seem to get it working despite the fact that it should be correct.

    • @matthewhennegan839
      @matthewhennegan839  Před 7 lety

      I think a little while ago they changed the actual parameters so if you're copying my syntax it won't compile. If you go to about 5 minutes into the video, I explain how to go to the class the event dispatchers are declared in, and copy the up to date signature, that will always work.

    • @DFILL450
      @DFILL450 Před 7 lety

      Thanks for the quick response. I got beginoverlap working with the new signature and endoverlap should be working with the new signature, but it's not.
      Function:
      UFUNCTION()
      void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
      Binding:
      BoxCollision->OnComponentEndOverlap.AddDynamic(this, &ADisplacementTankSlot::OnOverlapEnd);

    • @jani14jani
      @jani14jani Před 5 měsíci

      I know this comment is over six years old but incase anyone is having trouble with this. During UE 5.3 the signature is
      void OnDelegateExampleOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)