A Great Way To Setup POWERUPS In Your Unity Game

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 93

  • @headed_weast
    @headed_weast 2 ปีที่แล้ว +25

    5 uploads in 5 days. Man’s is on fire.

  • @williamandrade1455
    @williamandrade1455 2 ปีที่แล้ว +19

    Instant sub, the video was clear, precise and you go straight to the point!

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว

      Awesome, appreciate the support!

  • @AaronAsherRandall
    @AaronAsherRandall 2 ปีที่แล้ว +3

    This is one of the few tutorials on TH-cam that I was able to go through the entire thing without any issues. And I am having to modify some of the code to fit my game logic, but this is so well explained. Thank you!

  • @Dylen
    @Dylen 2 ปีที่แล้ว +2

    This blew my mind, I got a sudden crave to reimplement all the systems in my game just so its nice and orderly like this

  • @godzillakingkongvenom
    @godzillakingkongvenom 2 ปีที่แล้ว +1

    Loving the rapid fire uploads!!! Keep it up

  • @FoilGames
    @FoilGames ปีที่แล้ว

    One of the best Unity/Code/Best Practices/Pattern I've ever seen.

  • @plutoniumbellamy1912
    @plutoniumbellamy1912 2 ปีที่แล้ว +1

    This channel will be perfect for our school project. Thank you!

  • @marcelfyi
    @marcelfyi 2 ปีที่แล้ว +7

    These videos are so helpful and well structured. Thank you!

  • @sandycolours641
    @sandycolours641 ปีที่แล้ว

    never heard of scriptable objects but they seem really helpful

  • @jakeduncan2721
    @jakeduncan2721 2 ปีที่แล้ว +3

    Best 5 days of my life

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว

      ❤️ We keep it going

  • @GGGUSZ
    @GGGUSZ 2 ปีที่แล้ว +3

    You are one of the best game developer youtubers I've seen in a while. This is absolutely amazing!!

  • @JakeMakesGames
    @JakeMakesGames ปีที่แล้ว

    holy heck, im currently going through the process of re-writing the item system in my game and the way you've shown in this video is WAY more effective and time efficient to the way i originally programmed it! thank you so much

  • @CosmicComputer
    @CosmicComputer 2 ปีที่แล้ว +1

    You’re absolutely killin it

  • @eileeng2492
    @eileeng2492 2 ปีที่แล้ว +2

    Keep them coming.
    Amazing!!

  • @Pdr0fsa
    @Pdr0fsa 2 ปีที่แล้ว

    Dude, congratulations on the video. Really helpful! Thanks a lot!

  • @officialchaser8
    @officialchaser8 ปีที่แล้ว

    I gotta say this was a SUPER helpful tutorial! Tysm!

  • @junhyeokjeon815
    @junhyeokjeon815 2 ปีที่แล้ว

    one video per day.. what the hack~~ you are amazing dude

  • @guydoesthings7580
    @guydoesthings7580 2 ปีที่แล้ว +1

    Why do i find this after i have already implemented a powerup system + i don't use unity,
    Still this is an simple to follow understandable, and clean tutorial and i subscribed

  • @soulessnic1158
    @soulessnic1158 ปีที่แล้ว

    This is brilliant and clear, thank you for the tutorial!

  • @Fragler01
    @Fragler01 2 ปีที่แล้ว +16

    Nice video! I have a question though. How would you fade a speed buff away? Usually a speedbuff of this kind only last for 15-20 seconds or so (they are temporary). Where would you inplement the logic? I don’t think that it would fit in the scriptabale object part, since it depends on time, but if you write it in the script which inherits from the monobehaviour class, then it would loose its sense, since it would not be a general solution anymore…🤔🤨
    I’m very curious of your anwer.
    Keep up the good work! 😁

    • @Xelfist
      @Xelfist ปีที่แล้ว +1

      i think it should be on the player controller and the powerup simply activates it, in this case it starts a timer

    • @MrValiantrobe
      @MrValiantrobe 6 หลายเดือนก่อน

      For anyone reading this now, what I did was similar to what Xelfist suggested. On my Player class, I made a PowerupEffect currentBuff variable and a bool for whether or not we're buffed, and a timer for the buffs. I also added an "UnApply" function to PowerupEffect. For non-timer based powerups, we just leave this function empty. In timer based powerups, we send in the buff being activated to the player, so now the player has access to the UnApply method for this buff.
      The player has a "BuffMovementSpeed" method that has taken in the buff and amount, applied it to the Player's movement speed, started the buff timer which counts down in Update, and once it hits 0, we call "currentBuff.UnApply(this.gameObject)" in Update function. We send the player gameobject back to the speedbuff, so the speedbuff can unapply the exact speed boost it applied to the player's movement. I send a gameobject in because my PlayerMovement script is a separate script from the player and it's easy to access through GetComponent in the speedbuff class.
      My way means you'd only have one buff active at a time, but if you want multiple buffs active you may have to play with a dictionary that maintains the duration of each buff and a collection of each buff on the player, and update is continuously updating the dictionary with new timers for each buff. If player walks over a buff that already exists in their activebuffs dictionary, just add time to that buff's timer.

  • @Chowbogan
    @Chowbogan 2 ปีที่แล้ว +4

    I always assumed that if you did Destroy(gameObject) that nothing after that would run because the object with the script on it would have been destroyed, but is that not the case? Does it finish running that code block even though the object has been destroyed?

    • @Chowbogan
      @Chowbogan 2 ปีที่แล้ว +4

      "The object obj is destroyed immediately after the current Update loop, or t seconds from now if a time is specified." I looked it up, good to know!

  • @lucianbodnaresku6568
    @lucianbodnaresku6568 2 ปีที่แล้ว +1

    that's actually a good video no cap

  • @SelaMalka
    @SelaMalka ปีที่แล้ว

    Your videos are great dude, keep it up, I subbed

    • @BMoDev
      @BMoDev  ปีที่แล้ว +1

      Thanks ❤️

  • @remigodin9103
    @remigodin9103 2 ปีที่แล้ว +8

    Great video! I have a request; could you show how to to expand on this system to create, for example, a speed buff that decreases over time? Like it gives you 10 move speed buff that decreases linearly to zero in 5 seconds. I have difficulty figuring this out on my own.
    Thanks!

    • @lucasbernard971
      @lucasbernard971 2 ปีที่แล้ว

      using UnityEngine;
      namespace PowerUp
      {
      public class SpeedBuffPowerUp : MonoBehaviour
      {
      [SerializeField] float _currentSpeedBuff = 0f;
      [SerializeField] float _maxSpeedBuff = 10f;
      [Space]
      [SerializeField] float _currentDuration = 0f;
      [SerializeField] float _maxDuration = 5f;
      [Space]
      [SerializeField] bool _isActive = false;
      private void Update()
      {
      if (_isActive)
      {
      _currentDuration -= Time.deltaTime;
      float _normalizedDuration = Mathf.InverseLerp(0, _maxDuration, _currentDuration);
      _currentSpeedBuff = Mathf.Lerp(0f, _maxSpeedBuff, _normalizedDuration);
      if (_currentDuration < 0)
      {
      DisableBuff();
      }
      }
      }
      public void EnableBuff()
      {
      _currentSpeedBuff = _maxSpeedBuff;
      _currentDuration = _maxDuration;
      _isActive = true;
      }
      public void DisableBuff()
      {
      _currentSpeedBuff = 0f;
      _currentDuration = 0f;
      _isActive = false;
      }
      ///
      /// The Player script can get this method and add to his current speed.
      ///
      ///
      public float GetSpeedBuff()
      {
      return _currentSpeedBuff;
      }
      }
      }

    • @abhayanand3115
      @abhayanand3115 2 ปีที่แล้ว

      Use Mathf.Lerp() function.

  • @SirJawesome
    @SirJawesome 2 ปีที่แล้ว +4

    Love the video, this was a super practical breakdown of scriptable objects. But, how would you go about adding a temporary effect? If you wanted to only give the player increased speed for 5 seconds, how would you take away the power up?

    • @lucasbernard971
      @lucasbernard971 2 ปีที่แล้ว +2

      I think the Player could have a Monobehaviour with the effect method and the Scriptable Object just get the component and invoke it.

    • @pchas1
      @pchas1 2 ปีที่แล้ว +1

      You could also use a coroutine in order to regulate powerup times

    • @marjoaesp
      @marjoaesp 2 ปีที่แล้ว +1

      I'm kinda late but did u find a way to do it ? i couldn't.

  • @jamescriddle9312
    @jamescriddle9312 2 ปีที่แล้ว

    Great tutorial, thanks!

  • @SeanWonder
    @SeanWonder 10 หลายเดือนก่อน

    This is great! Been trying to find a guide like this. Any tips on how to apply this sort of concept to a weapon system? As in an object that can only access the shooting mechanic after picking up an item upgrade? Been making top down space shooter and trying to implement this type of mechanic. Great video thanks again!

  • @azazelgaming6573
    @azazelgaming6573 ปีที่แล้ว

    I was always scared of Scryptable Objects but it doesnt look that hard anymore, thanks.

  • @r3mc102
    @r3mc102 2 ปีที่แล้ว +2

    my player is a prefab and it throws an error when it tries to apply health to the player, how to fix it with a spawned player as it is tagget as a clone?

  • @EternalFlame1337
    @EternalFlame1337 2 ปีที่แล้ว

    Honestly your videos are really good but you know whats better than that?
    me being pin- Your picture, that picture is a solid 10/10

  • @tincoES
    @tincoES 10 หลายเดือนก่อน

    brilliant tutorial thanks a lot

  • @suicune2001
    @suicune2001 2 ปีที่แล้ว +8

    Handy! I definitely need to practice this. I feel something like a visual novel would be a good use for scriptable objects.

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว +2

      Yeah that'd be great, anything UI related I think is a perfect match for scriptable objects

  • @MosesMatsepane
    @MosesMatsepane 2 ปีที่แล้ว

    Geat tutorial, and clean code. So in practice, would you then use a State Machine to control the power up states?

  • @Mine-el3kz
    @Mine-el3kz 8 หลายเดือนก่อน

    thank you bro, keep it up

  • @D1nVies3l
    @D1nVies3l 2 ปีที่แล้ว

    great video ser, no bs just as I like

  • @jimmyyu3383
    @jimmyyu3383 2 ปีที่แล้ว

    Good tutorial. Learned something new. Btw, I use enum to classify PowerUpType to minimize number of scripts. As I am new to programming, not sure if using enum is a better option.

  • @roygatz
    @roygatz ปีที่แล้ว

    you did a fucking great job! really enjoy your video

  • @TheEarlPH
    @TheEarlPH 2 ปีที่แล้ว

    You are uploading almost everyday, nice. Quick question, How can i randomly spawn the power ups in the world? And what is needed for temporary power ups?

  • @mandamoon9149
    @mandamoon9149 2 ปีที่แล้ว +6

    After watching this, I really powered up my boss moves 💥

    • @jakeduncan2721
      @jakeduncan2721 2 ปีที่แล้ว +2

      Every time I see a BMO vid drop i feel like i just picked up a powerup

  • @crazyfox55
    @crazyfox55 2 ปีที่แล้ว

    Duration seems tricky to implement. How would pausing work? How would a turn based game work?

  • @gabangang5093
    @gabangang5093 2 ปีที่แล้ว

    this is great, how about a power up with a timer, lets say for 1 1minute the power up stays on the player and then player back to normal..

  • @Luis96ef
    @Luis96ef 2 ปีที่แล้ว

    I guess it would also work if you used a list of power up effects and a for each in the trigger method if you wanted to make a bigger power up item right? So it applies more than one effect

  • @Fremdscham-uu3xv
    @Fremdscham-uu3xv ปีที่แล้ว +1

    Thank you bro but what about if I want to achieve overtime effects? Like how can I make heal over time or get a speed buff for 10 seconds?

    • @mateovajda6078
      @mateovajda6078 5 หลายเดือนก่อน

      i think i would know how to make a speed buff for 10s. so try to make a timer, which you can look up on yt how to do, which counts for an x amount that feels right (you make it with time.deltaTime) and you put the code that gives you the buff in that while loop where your timer is also try to make the timer stop when it finishes, because if your game lasts long, the timer might count high up which may cause lag. i am awfully sorry for a 10 month late answer, but i hope this worked and helped

  • @AugustMeyer
    @AugustMeyer 2 ปีที่แล้ว

    need a tutorial for that last power

  • @brodakarat6340
    @brodakarat6340 ปีที่แล้ว

    Is this pretty close to the decorator pattern

  • @789blablajaja
    @789blablajaja 2 ปีที่แล้ว

    Dont forget to make the field private though. As everything written to the SO will be serialized and stored.

  • @noisemaker0129
    @noisemaker0129 2 ปีที่แล้ว +1

    Amazing tutorial. I was confused a bit by the apply method, and I think you could spend another minute or two explaining some of that c# magic for us humanities programming noobz ;)
    Still, this is great

  • @Ryan-pm3bg
    @Ryan-pm3bg 2 ปีที่แล้ว

    You can destroy a game object and the next line of code will still be run? I always assumed it would just end.

  • @paranoia985
    @paranoia985 2 ปีที่แล้ว

    Please, make a video on how did u make Isaac animation. I'm new to Unity and it is very difficult to me.

  • @cuchud3266
    @cuchud3266 ปีที่แล้ว

    Thanks for the tutorial, easy to follow. Do you know how can I destroy the game object the scriptable object is referenced in? Or how can I NOT destroy the gameobject if the health is full?

    • @mateovajda6078
      @mateovajda6078 5 หลายเดือนก่อน

      i think i would know the answer to the second question. try to make a bool in the health script which checks if the health is full or not. reference the health script in the powerup script an make an if statement: if !healthIsFull then destroy the game object. i may be 9 months late to your question but i so hope it helped and it will work.

  • @Pedro-zh6kk
    @Pedro-zh6kk 4 หลายเดือนก่อน

    cant drag the powerup inside the power up effect variable in inspector.

  • @NodrapLego
    @NodrapLego 2 ปีที่แล้ว

    So when you want to add different images and perhaps particles to the pickup wouldn't you use a prefab for that and so don't need to use SO's at all? Wouldn't prefabs and variants be perfect for that?

    • @max.playsgames
      @max.playsgames 2 ปีที่แล้ว

      the SO is handling the actual changing of the stats, the object that is sitting in the scene is just a container to hold the SO so you can use prefabs to make it look however you like, as long as that object in the scene has a trigger collider it will give a powerup using the SO

  • @jimmyljr95
    @jimmyljr95 2 ปีที่แล้ว +1

    My comments on the next few videos will have a secret message you must put together in order to save the hooman race.... TeeHEE

  • @modelworkzseo
    @modelworkzseo 2 ปีที่แล้ว

    Subbed!!

  • @mrloquendo3
    @mrloquendo3 ปีที่แล้ว

    how to create a lootbag system with this power up or buff objects?

    • @BMoDev
      @BMoDev  ปีที่แล้ว

      I have a loot system tutorial

  • @russmacc316
    @russmacc316 2 ปีที่แล้ว +2

    Hey BMo, thank you for your concise yet informative videos, you take the time to explain what is going on and I really appreciate it. I have a question, would you mind showing how you have your player health and max health set up? Are they scriptable objects as well? I followed pretty closely and I think I have everything set up correctly, but my existing health script is making the target.GetComponent part of the buff script throw a NullReferenceException, and I'm 99% sure it's due to my scripts, not yours :)

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว +3

      Hey thanks! I'm using a special scriptable object variable for my health/maxHealth (th-cam.com/video/VFOGGml_N6g/w-d-xo.html)
      ...but you can 100% just use floats!
      public float health;
      public float maxHealth;
      public void TakeDamage(float amount) {
      health -= amount;
      }

    • @russmacc316
      @russmacc316 2 ปีที่แล้ว

      @@BMoDev Awesome, thank you! I am going to watch your video and likely rip my code up because your way seems to be much more efficient to keep track of in the long run. Watching the other video now :)

  • @hamsg
    @hamsg 2 ปีที่แล้ว +4

    This is great for little simple games. Could you make a video on a more complex system like handling buffs from a BuffList on the player with durations etc?

    • @FullMe7alJacke7
      @FullMe7alJacke7 ปีที่แล้ว

      That sounds like a less than ideal implementation. The buff should be responsible for it's own behavior.

  • @justahuman4862
    @justahuman4862 2 ปีที่แล้ว

    great vid

  • @Blitx924
    @Blitx924 2 ปีที่แล้ว +1

    Great vid but I believe it’s over complicated you could do a on collision put whatever buff you want and then destroy the game object

  • @VEOdev
    @VEOdev 2 ปีที่แล้ว

    I rather make a normal script as a parent and then powers as child so I don't have to create minor and major buff for each one or a debuff when the only this that changes is a value , just make 1 script and than duplicate the game object and change the value and that's all

  • @_Garm_
    @_Garm_ 2 ปีที่แล้ว

    Awesome ++ :D

  • @retiredvegta6697
    @retiredvegta6697 2 ปีที่แล้ว

    Character? You mean issac from the binding of issac

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว +1

      Yep

  • @AndrewYakymetsLS
    @AndrewYakymetsLS 5 หลายเดือนก่อน

    Hi, please note, the ScriptableObject doen't have Start and Update functions. From your video it sound like removing them is an option (1:40+-), but that;s wrong... From the official documentation, ScriptableObject only has Awake, OnEnable, OnDisable, OnDestroy, OnValidate, and Reset.

  • @KrucLeo
    @KrucLeo 2 ปีที่แล้ว +6

    This is a common mistake we've seen juniors make.
    This approach is highly error-prone as it requires you to mirror duplication and subtraction code, forces specific method invocation order, and obscures debug information.
    Use the interface decoration. An immutable parameter struct data object, and stack of modifiers that expose a single Modify method that accepts and returns mutated parameter objects down the chain. This will give you a highly expressive and dynamic stack that allows more complex effects, application order visibility and comfortable debugging. An additional effect of modifier stack is an ability to preview stack changes without affecting the modifiable entity until you need to.
    Having a change preview for parameters applied by items or effects, is a common feature. It's a hell to adapt add/sub approach for that.

    • @chronicle325
      @chronicle325 2 ปีที่แล้ว +1

      Would love to see a video about that :)

    • @johnleorid
      @johnleorid 2 ปีที่แล้ว +3

      Why do you use such complex words? Just say that there should be a list of modifiers added by an interface instead of GetComponent() calls to directly modify variables.
      What I don't quite understand is how you know which variable to modify. A Dictionary with an Enum? String? Reference? And what you mean by preview before applying.

    • @robbybobbijoe
      @robbybobbijoe ปีที่แล้ว +2

      Make a video about it then if you're going to give such harsch criticism with no actual proof of you being able to create something like that.

  • @IlLupoAC
    @IlLupoAC 2 ปีที่แล้ว +1

    Hi, I'm getting an error regarding the target.GetComponent().jumpForce.value += amount; section of this tutorial. Debug message states 'float does not contain a definition for 'value''. I'm looking around for clues for fixing this, but I would love some help if you have the time :]
    EDIT: I removed .value and it works now. Hopefully!

    • @mochimochi1857
      @mochimochi1857 2 ปีที่แล้ว

      have the same problem but removing .value didn’t work :’) asking for any help!

  • @IROC___Jeff
    @IROC___Jeff ปีที่แล้ว

    How would we get this to work on say a bullet prefab for a weapon powerup? I made a field in the new script for a prefab like "amount" in the video called BulletPowerUp. In my Player script my prefab is named BulletPrefab. What do I have to do to the target.GetComponent part for this to work, if possible.
    target.GetComponent().BulletPrefab