C++ Health & Damage System UE4 / Unreal Engine 4 C++

Sdílet
Vložit
  • čas přidán 21. 08. 2024

Komentáře • 45

  • @DevEnabled
    @DevEnabled  Před 5 lety +11

    In this video, we implement a simple health component which will for simple implementation of health to any other Pawn or Actor class in your games.

    • @user-nn5st8qm5v
      @user-nn5st8qm5v Před 3 lety

      This is a great tutorial, but you don't need to check Damage

    • @YehiaMohamedDakhly
      @YehiaMohamedDakhly Před 3 měsíci

      @@user-nn5st8qm5v In Unreal Engine, the `OnAnyDamage` event is typically not called if the damage value is less than or equal to zero. This is because damage values that are non-positive usually indicate that there is no actual damage to process, and thus the event doesn't need to be triggered.
      However, including the check for `Damage

  • @xylvnking
    @xylvnking Před rokem +5

    For anybody in the future. I'm running UE5.1
    My UFUNCTION() is
    void TakeDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);
    and then binding that to the owner function within the cpp file is
    AActor* MyOwner = GetOwner();
    if (MyOwner) {
    return;
    MyOwner->OnTakeAnyDamage.AddDynamic(this, &UHealthComponentSecond::TakeDamage);
    }
    It's frustrating having to use outdated tutorials (even the official documentation is outdated right now) but always remember that if you aren't struggling, you aren't learning. Good luck.
    Great content btw, not much you can do as updates happen haha.

  • @plinyvicgames
    @plinyvicgames Před 11 měsíci +1

    just wanted to say im really glad you take a "modular" approach that so many tutorials do not take. coming from several years of unity, it has been a little painful watching some tutorial videos as they leave little room for further implementation or expansion. good video!

    • @DevEnabled
      @DevEnabled  Před 11 měsíci

      Thanks. I'm getting a lot of Unity comparisons recently, I wonder why... But yeah, component based workflows are heavily overlooked in unreal which is unfortunate. My upcoming content will have a stronger focus on that too.

  • @zeeshanparvez5235
    @zeeshanparvez5235 Před 3 lety +5

    You have good videos. Please don't abandon your series on Unreal Engine in the middle like most people

    • @DevEnabled
      @DevEnabled  Před 3 lety

      Thanks, I guess you mean the C++ series specifically rather than just Unreal in general?

    • @zeeshanparvez5235
      @zeeshanparvez5235 Před 3 lety +1

      @@DevEnabled Yeah, there are very few good free series on C++. You have a great way of explaining everything.

  • @user-bv4xr3yd8w
    @user-bv4xr3yd8w Před 5 měsíci

    This is awesome -- never thought about making things such as the health modular! This is such a great tutorial generally for how actor components can help you separate out things from your character scripts. Thank you!!!

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

      Great to hear a new solution has been presented. Components are a very flexible way to work.

  • @trfff0
    @trfff0 Před rokem +1

    This was - if not the best - a great showcase and explanation while providing a practical toolset I can use further into my project. Health component may be simple, but the knowledge gained is massive. You are really good at this, and I can't wait to watch more!

  • @JohnHeartTV
    @JohnHeartTV Před 2 lety +4

    If you can't compile due to declaration of 'Owner' hides class memeber.
    Change AActor* Owner to MyOwner (or any other variable name that is not 'Owner'). That solves it.

  • @manuelglez9347
    @manuelglez9347 Před 3 lety +1

    Best Unreal tutorials on youtube!

    • @DevEnabled
      @DevEnabled  Před 3 lety

      Appreciated, always great to know they're helping.

  • @Krilium
    @Krilium Před 3 lety +1

    Doing a Udemy course called ‘Pro Unreal Engine Coding’ by a guy called ‘Rob B.’ I thought you sounded a little like him. Then I found out you’re a Rob B. too!
    You’re not the same person of course but I instantly trust you lmao

  • @JPAS-YT
    @JPAS-YT Před 5 lety +2

    wow I was searching for this! Thanks!

  • @tigerpunchsportsclub8366

    Thanks, for showing the C++ implementation

  • @mikkelbugge7299
    @mikkelbugge7299 Před 4 lety +3

    Noticed that at least here in 4.25 the first parameter in the signature you copy from is now an AActor OnTakeAnyDamage, and NOT the AActor* object in the video. Including this will give you some fancy C2664 error, but simply removing the first AActor object fixes everything.
    Other than that, thanks for teaching me about ActorComponents. I could've used them far long ago to avoid the mess my character is.

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

      Thanks, Mikkel, that is quite likely a 4.25 update then. There've been a lot of changes in the latest version that seems to have changed and approaches I've become familiar with no longer work. Some of the other videos in this playlist have commented saying that certain parts don't work. I am currently going through a new playlist on C++ covering more basic concepts so I might redo these videos too to account for the recent changes. Good to hear you found the solution though and thanks for sharing.

    • @wolf5370
      @wolf5370 Před 4 lety +3

      Ran into this too [4.25.1] - wish I'd seen your comment a half hour earlier, ran my tail in circles for a while (it gives the error on the call to the delegate line "Owner->OnTakeAnyDamage.AddDynamic(this, &UWhateverComponent::TakeDamage);") - fix, as stated, is to remove unneeded 'AActor OnTakeAnyDamage' param entirely. Cheers Mikkel.

    • @rushikeshbhandare8946
      @rushikeshbhandare8946 Před 4 lety

      Thanks bro, helps a lot

    • @DevEnabled
      @DevEnabled  Před 4 lety

      @@rushikeshbhandare8946 Great to hear.

  • @firnekburg4990
    @firnekburg4990 Před 5 lety +2

    I've learned a lot, thanks sire.
    Please implement c++ event dispatchers in upcoming tuts :D
    Cheers !

  • @rpgprime
    @rpgprime Před rokem

    Great tutorial, just used it in 5.1 thanks!

  • @TM-jb8bw
    @TM-jb8bw Před 4 lety

    So good! keep em coming! best youtuber for Unreal and c++!

  • @kirillkudinov4219
    @kirillkudinov4219 Před rokem

    Perfect

  • @user-ke1xp2ok8m
    @user-ke1xp2ok8m Před 2 lety

    Thanks for the video, helped!

  • @gabrielepardi5178
    @gabrielepardi5178 Před 3 lety

    Thank you very much!

  • @asmaloney
    @asmaloney Před 5 lety

    Thanks for the playlist!
    Small buglet in the name of the video: "Damage", not "Damange"

    • @DevEnabled
      @DevEnabled  Před 5 lety

      thank you and thanks for mentioning it, I missed that somehow.

  • @Dekisan
    @Dekisan Před 4 lety +2

    I was just testing some values and I noticed that when I changed the DefaultHealth in the editor that the health is still 100 instead of the new value I had put in the editor. Is there something I'm missing or would I need to set the health = DefaultHealth in the constructor in blueprint?

  • @LawMasterTimmy
    @LawMasterTimmy Před 4 lety +2

    Hello, at 13:00 it does not show any health component. Any help would be appreciated

    • @ftwgaming0
      @ftwgaming0 Před 4 lety

      If you've been following the tutorial closely and it hasn't shown up, try recompiling it in-engine. Make sure the name you're using is correct too.

  • @simpill81
    @simpill81 Před 4 lety

    Hey as far as handling damage. Should I just use the built-in functionality provided by unreal or create my own functions? I am going to have a couple types of damage that apply damage with some accompanied effects. Ie) Run through fire: damage over time, Run over Ice: slow character movements speed.

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

      Depends on the project really. Having your own health system can be useful but also overkill for smaller projects. For what you mentioned I'd probably roll a custom health system but even then you could assign the existing damage type to different elements. There's no right or wrong answer really so sorry for the washy answer there.

  • @spanksouls7714
    @spanksouls7714 Před 4 lety +2

    How is ur Compiler ignore the MyOwner Error, in my code it giving me error and wont build the code.

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

      That just means I didn't have an error there, the compiler won't ignore an error and just compile. Either something has changed since I released the tutorial, so you might want to check the documentation for the version you're working in. Or you've missed something somewhere else in the code that relates to the MyOwner variable.

    • @Erebus2075
      @Erebus2075 Před 4 lety

      @@DevEnabled your compiler is marking it red. it is also not an attribute added anywhere it can access.
      think it is ignoring it completely.

    • @SlumpogMillionaire
      @SlumpogMillionaire Před 4 lety +3

      For me I had to #include "GameFramework/Actor.h" in the .CPP file

    • @meritxellcosta7357
      @meritxellcosta7357 Před 4 lety

      @@SlumpogMillionaire Thank you! You got it!

  • @winnersheep
    @winnersheep Před rokem

    I want to play hit animations that have different enemies depending on the player's attack motion
    Can you help me?

  • @interneth7644
    @interneth7644 Před rokem

    7:48

  • @SurviveOnlyStrong
    @SurviveOnlyStrong Před 2 lety

    VS doesn't find anything, I guess it's because of 'hide external dependencies folders' setting that I've set to true previously.
    But I can't set it back to false, this settings is greyed out now, any advice on how to fix this?