Unity Status Effect System With Scriptable Objects | Damage Over Time, Movement Penalty

Sdílet
Vložit
  • čas přidán 23. 08. 2024
  • 🚨 Wishlist Revolocity on Steam! store.steampow... 🚨 If you want to learn how to create a status effect system in Unity using Scriptable Objects, this is the video for you! Our debuff system will be very modular allow for a lot of variety with just a few scripts!
    Three starter scripts (Free): / 61162389
    Full project files (Patreon Only): / 61162444
    Starter Asset FPS Controller: assetstore.uni...
    Scarecrow: sketchfab.com/...
    📁 Get access to my tutorial project files over on Patreon: / danpos
    💬 Join in with the Blender and Game Dev conversation over on The Creative Magpie Discord Server: / discord
    ❤️ Find me elsewhere on the internet:
    Gumroad: gumroad.com/da...
    Twitter: / danpos_
    Instagram: / danpos_
    📜 If you like this video and want to develop your skills I can highly recommend the following courses I have taken*:
    Blender 2.8 Launch Pad Course: academy.cgboos...
    Substance Painter Launch Pad: academy.cgboos...
    Unreal Engine Blueprint Game Developer:
    click.linksyne...
    Unreal Engine C++ Developer:
    click.linksyne...
    Blender 3D Sculpting for Beginners: click.linksyne...
    Beginning C++ Programming:
    click.linksyne...
    The Ultimate Guide to Game Development With Unity:
    click.linksyne...
    🖱️ This is the gear that I use to create*
    Lenovo L24Q - QHD 24" Monitors: amzn.to/3s6Rba0
    BONTEC Dual Monitor Arm: amzn.to/3s7tgr1
    Logitech G213 Keyboard: amzn.to/38pe3tq
    Logitech Z333 2.1 Speaker System: amzn.to/2LBdNic
    Logitech 720p Webcam: amzn.to/39eyecG
    Blue Yeti Microphone: amzn.to/2Le7EbB
    Corsair VOID ELITE RGB Headphones: amzn.to/35i50bB
    Corsair Harpoon RGB Optical Gaming Mouse: amzn.to/3olwCUV
    Corsair iCUE LS100 Smart Lightin Strip Starter Kit: amzn.to/3q5mMXP
    Corsair iCUE 465X RGB Case: amzn.to/3noyNpp
    Corsair Hydro 100i RGB Cooling System: amzn.to/3q0K8xH
    RTX 2060: amzn.to/35kewLF
    Large Mouse Mat: amzn.to/2MEQdBn
    Gel Wrist Rest: amzn.to/3bj3Pg0
    Video Music Provided by EpidemicSound: www.epidemicso...
    *These are affiliate links which means I receive a small commission if you decide to buy something - the price will be no different to you though! I would massively appreciate any support :) *

Komentáře • 24

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

    Very helpful video!
    I added a little bit to suit my needs. Instead of reading-only from the ScriptableObjects, I write on them. To prevent the data persistence, I created another set of variables with "_initial" on them, I then set the vars without "_initial" to the initials to reset them. This is to stack the same effects and have multiple different effects without creating multiple variables in Enemy.cs.
    I also used a list of the ScriptableObject to add and remove the effects, and to apply each effect each frame. If the effect you want to apply is still being applied, meaning it should stack, I just added the lifeTime to the remaining lifeTime of the existing effect.
    Thank you for the wonderful video! I wouldn't have thought of using ScriptableObjects if not for you.

    • @DanPos
      @DanPos  Před 2 lety +1

      Hey thanks for the comment and I'm glad you found it useful!

    • @reendevelops
      @reendevelops Před 2 lety

      @@DanPos No problem. Keep up the good work!

    • @DanPos
      @DanPos  Před 2 lety

      @@reendevelops I shall, is there anything in particular you'd like to see?

    • @DowsodsaiZ
      @DowsodsaiZ Před 2 lety

      @@DanPos I really like your statuseffect structure , maybe you could share some video of stacking debuff effect tutorial because there are a few in the google... really hard to find the solution.

    • @Legionope
      @Legionope Před 2 měsíci +1

      Wait.. Does that actually work correctly in your compiled Built as well?

  • @MrMattyMoses
    @MrMattyMoses Před rokem

    This was really cool to watch. It's neat watching you troubleshoot as you go and some of the text popups cracked me up lol! Thanks for making this video.

    • @DanPos
      @DanPos  Před rokem +1

      Glad you enjoyed it!

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

    I found this video to be super helpful! I haven’t fully implemented it because I haven’t set up my enemies fully, but I did change some things. (This also means I didn’t add the actual adding / subtracting of health or anything, yet.)
    I love ScriptableObjects, so I made a parent stat effect class then children for the types (IE DOT, HOT, Movement) so there aren’t unnecessary variables in them. Then, I created the methods in the SOs (as much as I could in the parent and then added specifics like DOT amount in the child’s class. That way if I add them to more than just enemies (like chests or whatever) I don’t have to rewrite code. I haven’t decided how to do multiple effects or stacking, yet, though. Lastly, I added the status effect SO to the spell SO so it’s auto connected. A part of me wonders if it’d be better to just put them all in one SO, (like healing spell that has HOT ability in the spell instead of as a separate effect) but for now I like it. 😊

  • @ssalovaa
    @ssalovaa Před rokem +3

    Wouldn't it be better to have each status effect have its own class?

  • @atrs
    @atrs Před rokem

    Finally managed to get my status effects working on enemies for my Tower Defence game I am working on, Thank you so much!
    However I am a bit new to Unity and programming games, so I am a bit confused when it comes to stacking the status effects since im working in 2D i am not worried about particle effects at the moment but i would definitely like to stack for example Slow and DOT effect

  • @DanielAttaway
    @DanielAttaway Před rokem

    Super helpful video, thanks a bunch!

  • @khizarrahim9332
    @khizarrahim9332 Před rokem

    Great video. Can you please guide a way to make a freeze status effect as well. I really need it for a game i am working on and i have no help

  • @kashifraja8451
    @kashifraja8451 Před 10 měsíci +1

    doesnt seem like this way multiple statuses would work. so if i applied a slow then a DoT

  • @csr3846
    @csr3846 Před 2 lety +1

    I'm trying to create a buff system my self. So this was somewhat helpful. Although, are there not a more clean approach to this? Doing all the logic for all the spells/buffs in the enemy script doesnt seem great. What if you had 50+ functionalites?

    • @DanPos
      @DanPos  Před 2 lety

      If you had 50+ functionalities I feel that would end up being bad game design because a player would need to keep track of 50+ statuses and what each of those mean.
      If you needed that many though you could refactor it so the scriptable effects got a reference to the enemy and then handle the logic on the scriptable object itself.
      The way I outlined presumes you will have a few set effect types similar to other games such as DOT, slow, instant damage etc.

    • @csr3846
      @csr3846 Před 2 lety

      @@DanPos Right, thanks for the reply!

  • @AndroidACArcana
    @AndroidACArcana Před rokem

    Helpful video, thank you.
    I'd like to suggest for readability and good variable naming that TickSpeed should instead be called TickIntervalSeconds, and Lifetime should be called LifetimeSeconds in order to convey a unit and how they are used.

  • @osdelhdez6796
    @osdelhdez6796 Před 5 měsíci +1

    Good video for beginner but this implementation is bad. You are coupling the status effect with the enemy behavior. The enemy behavior should be independent from the status effects. You can have a component that holds the status effect logic, then that component can reduce the move speed or apply damage to the enemies. No need to touch the enemies movement or health controllers, the logic should be within the status effect manager/controller. Also, you only need to instantiate once, since it is an expensive operation

  • @admkerby3765
    @admkerby3765 Před rokem

    Hello! Thank you so much for making so many videos. You are moving in the right direction, but the clean of your code is very lame. You are violating the rule of sole responsibility. The ENEMY class should not know about ticks, the lifetime of the spell, and so on. The EFFECT must affect the ENEMY completely and be destroyed when it ends. You attached the particles as a child object to the ENEMY. So why don't you create an EFFECT game object that will contain particles and scripts and sounds and whatever you want. And when the EFFECT ends, it will simply cause destroy on itself. Good progress for you! I'm looking forward to your new videos!

    • @enursha13drs
      @enursha13drs Před rokem

      if the enemy moves, and they aren't parented to it, the effect stays in pl,ace...

    • @AndroidACArcana
      @AndroidACArcana Před rokem

      @@enursha13drs I'm pretty sure they intended for the Status Effect object to be a child of whatever it is affecting.