Everyone who's having issues with the code, here's the complete script: github.com/nickbota/Unity-Platformer-Episode-8/blob/main/Assets/Scripts/Health/Health.cs ● Support the channel on Patreon or UA-cam: www.patreon.com/pandemonium_games ua-cam.com/channels/pkMj5b5kl2_YApDvgUCVQQ.htmljoin ● Subscribe to the Weekly Pandemonium Newsletter: www.pandemonium-games.com/#:~:text=About%20Me-,Weekly%20Pandemonium,-Subscribe%20to%20our
For those of you who are unable to find the IEnumerator interface in Unity, if it's showing red line in the code, it's possible that you may have forgotten to include the System.Collections namespace in your script. IEnumerator is a part of the System.Collections namespace, so in order to use it, you need to ensure that your script has access to that namespace. So just write "Using System.Collections" at the top of your script.
Wow! I guess this was the last video of this series. It felt so awesome to understand the coding and other technicalities behind a 2D platform game. Thanks a million for taking me on this trip. Now I will try to make my own 2D Platformer from scratch. I wish you make such a series for making a turn based multiplayer 2D game. That would be so amazing!!!
Not the last one, literally finished the next episode yesterday, dropping it today. There will be 3-4 more episodes for sure until this is a playable game
For anyone else that loses the jump and attack animations around 7:24, it's because of the layers. When we set Player and Enemy to 10 / 11,the layers get screwed up in Player Movement Script. If you click on Player, look in the inspector and scroll to the Player Movement Script. Where it says Ground and Wall, make sure Ground Layer = Player, and Wall Layer = Enemy.
Heads up for people like me who couldn't get the invulnerability to work: Make sure the player and the enemy/trap are on the correct layers in the Inspector.
Okay, I have to ask you for some extra help again. So, I implemented the s code and it works as it should... with one exception. If the player is hit with two different things at the same time (which is most noticeable if you're standing on spikes and the saw when your s run out), you take damage from both of them at the same time. I would like to change it so that you only take damage from the strongest single hit you took if two things hit you at the exact same time. I understand the chances of getting hit twice in a single frame is exceptionally low, but I still want to ensure it can't combo out the player needlessly.
Make a bool flag called something like "IsProcessingHit" or something. Set this true in the collision detection whenever the collision event fires. Now, at the top of your collision event have a conditional that checks if this flag is true, and if so, return out of the collision event and dont process any of the collision logic. Then set IsProcessingHit to false at the end of your Ienumerator once it is done with the invincibility time. Collision events (as well as any Unity API) runs on the main thread. This means they are all synchronous. Which means if a flag gets set to true in one collision event, by the time it gets to next collision event it will already be true and you will be able to essentially back out of the collision event. If you want to be able to process only the highest damage, you will have to do some additional work. The best thing to do is setup a data structure system that captures all damage processed by separate collision events and dont process the damage immediately in the collision event. Instead, inside of your update method have some logic checking this datastructure to see if has anything contained within it, then process the highest damage stored in that collection and throw away the rest. Collisions occur before any Update methods in the unity event order of execution, so you can basically delay the damage processing until you get to your update. This isn't technically the "best" way to handle it, but it is the easiest and will get the job done. Other methods would require much more explanation than I am able to provide in a single youtube comment.
Hello What if I have multiple body parts like legs, weapons, accessories and I also want them to have blinking effects when the player is damaged? Everything works just fine for me but the effect only affects the body and not the body parts I've mentioned. Thanks for the help:)
Not sure if you have a chance to read this comment, but I got everything working up until the saw so far, but whenever my character touches it, the die animation plays instead of the hurt animation, checked to make sure they are all in the right place & walked through everything a few times so a little confused.
Hi, the code is working fine for me, but eveytime iFrames activates the animations deactivates, the anims for walking and firing, I can only loop back to normal animations when I jump. is there something I did wrong?
Out of all things that could happen, the changing of the sprite color doesn't work for me. I am not sure why. The for loop works and the enumerator works as well. I checked everything with Debug.Log and it all seems fine. It's like the animations are more dominant and will not allow a color change. (And I am not changing any colors in the animations). The only difference is that I am using my own sprites. Do I maybe need to go with a certain setting for the sprites?
Man I got a problem. all things are working except that my player can only get hurt once and after that it became invulnerable the saw cant hurt it anymore. please help
I'm using your code, but it seems my character still keeps taking consecutive damage. Here in the video it seems to work, but in my game the player character can be hit back to back every time it collides with an enemy or a projectile. The only thing that works are the flashes. For an example, I created an enemy that shoots three bullets in rapid succession. All of these bullets can collide with the player and the player dies instantly. Three bullets, three HP. Same happens if I walk into a trap, walk out of it and quickly walk back into it. Interestingly if you stand on top of a trap the player doesn't take further damage as long as you don't move out of it. I wonder what's causing this? I'm using your code for health, enemies, taking damage and these i-frames.
Still don't work for me. All layers are the same as in the video, i even copied the github script and the error "NullReferenceException: Object reference not set to an instance of an object" comes up in unity
A basic timer will do the trick. Make a time variable somewhere, increase it by Time.deltaTime in the Update and when it becomes higher than X(let's say 120 seconds) increase the health and reset the timer.
Hi there, Everything works well, but one issue. I can't figure out what the exact trigger for that is, but while and after iFrames, while moving through the shown enemy, my player falls through the ground. Hope you'll read my issue and help ...
Correction: Figured out the problem are not the iFrames. It has something to do with the Enemy itself. I glitch through a point behind his body. What's the problem?
the player gets hit 2 times (once because the enemy attacks him and the second time because of the damage of collision wich you showed in eps 10) so he loses 2 lives before the Invincibility starts how can i fix that
Tried all your code and they match perfect, player still not receiving damage from the saw and hurting/dying, any thoughts as to why this may be the case and any help would be greatly appreciated. Thanks
Has anyone had any issues where after adding sorting layers, and going through the previous tutorials your player jumping and attacking animations won't play?
Go to the GitHub link of the episode you want to download and just download the zip archive. Unzip it and open it in UnityHub, should be simple. DM me on discord if you can't make it work
I really enjoy your contents even tho im new i already enjoy some of your videos, keep on. But i cant find your video game(Dive) on play store, thats sad, cause i wanted to support
Thanks for the support 🙏 here it is: play.google.com/store/apps/details?id=com.PandemoniumGames.DiveFinal It's not bringing in almost any revenue though, so if you like my videos just keep watching them, that helps more 😁
Please make tutorial if the enemy not see the player than the enemy shut patrol.. But if the enemy is see the player than the enemy is jump and jump.. :)
@@PandemoniumGameDev было бы круто запилить 3д шутер с атмосферной локацией. И загрузить его в стим. Готов тебе заплатить если доведёшь меня до конечного результата. Я веб разработчик, но сейчас что-то заинтересовал геймдев
Everyone who's having issues with the code, here's the complete script: github.com/nickbota/Unity-Platformer-Episode-8/blob/main/Assets/Scripts/Health/Health.cs
● Support the channel on Patreon or UA-cam: www.patreon.com/pandemonium_games
ua-cam.com/channels/pkMj5b5kl2_YApDvgUCVQQ.htmljoin
● Subscribe to the Weekly Pandemonium Newsletter: www.pandemonium-games.com/#:~:text=About%20Me-,Weekly%20Pandemonium,-Subscribe%20to%20our
For those of you who are unable to find the IEnumerator interface in Unity, if it's showing red line in the code, it's possible that you may have forgotten to include the System.Collections namespace in your script. IEnumerator is a part of the System.Collections namespace, so in order to use it, you need to ensure that your script has access to that namespace.
So just write "Using System.Collections" at the top of your script.
I love what you are doing in this series. It is very clear, concise, and relevant.
Thank you, appreciate the support and glad it's helpful 🙂
Wow! I guess this was the last video of this series. It felt so awesome to understand the coding and other technicalities behind a 2D platform game. Thanks a million for taking me on this trip. Now I will try to make my own 2D Platformer from scratch.
I wish you make such a series for making a turn based multiplayer 2D game. That would be so amazing!!!
Not the last one, literally finished the next episode yesterday, dropping it today. There will be 3-4 more episodes for sure until this is a playable game
@@PandemoniumGameDev Oh that's great! I'll be waiting for the coming lessons.
@@subharanjanghoshal5597 episode 9 is out. Next ones coming soon too 🙌
For anyone else that loses the jump and attack animations around 7:24, it's because of the layers. When we set Player and Enemy to 10 / 11,the layers get screwed up in Player Movement Script. If you click on Player, look in the inspector and scroll to the Player Movement Script. Where it says Ground and Wall, make sure Ground Layer = Player, and Wall Layer = Enemy.
Cant wait for the next video in this series!!!
Dude…..thank you u really made it very easy for a beginner like myself to understand, I still have ways to go but you gave me a great first step 👍
Great to hear that, thanks! Next episode is done and dropping today too
New here, very inspired by your series. Was gutted after Brackeys had gone, you sir are a legand.
Thanks a lot for the support and very glad that I can help :)
Heads up for people like me who couldn't get the invulnerability to work: Make sure the player and the enemy/trap are on the correct layers in the Inspector.
Just finished all of the current episodes very cool
Thanks a lot! next one coming in a couple day
2:55 I also added a [SerializeField] private bool trigger; so I can enable and disable the iFrames
Good idea, if you set the duration to 0 it's going to virtually disable it but a trigger does the job too.
Keep uploading i bet ur videos will explode someday!
i just now finished 2#
Certainly hope so :) good luck with it and let me know if you have issues
@@PandemoniumGameDev i think im fine now but kinda hard to understand what code does what but i think its bcz my English
Okay, I have to ask you for some extra help again.
So, I implemented the s code and it works as it should... with one exception. If the player is hit with two different things at the same time (which is most noticeable if you're standing on spikes and the saw when your s run out), you take damage from both of them at the same time. I would like to change it so that you only take damage from the strongest single hit you took if two things hit you at the exact same time.
I understand the chances of getting hit twice in a single frame is exceptionally low, but I still want to ensure it can't combo out the player needlessly.
Make a bool flag called something like "IsProcessingHit" or something. Set this true in the collision detection whenever the collision event fires. Now, at the top of your collision event have a conditional that checks if this flag is true, and if so, return out of the collision event and dont process any of the collision logic. Then set IsProcessingHit to false at the end of your Ienumerator once it is done with the invincibility time.
Collision events (as well as any Unity API) runs on the main thread. This means they are all synchronous. Which means if a flag gets set to true in one collision event, by the time it gets to next collision event it will already be true and you will be able to essentially back out of the collision event.
If you want to be able to process only the highest damage, you will have to do some additional work. The best thing to do is setup a data structure system that captures all damage processed by separate collision events and dont process the damage immediately in the collision event. Instead, inside of your update method have some logic checking this datastructure to see if has anything contained within it, then process the highest damage stored in that collection and throw away the rest. Collisions occur before any Update methods in the unity event order of execution, so you can basically delay the damage processing until you get to your update. This isn't technically the "best" way to handle it, but it is the easiest and will get the job done. Other methods would require much more explanation than I am able to provide in a single youtube comment.
Keep on making this video's you really gave us important lesson which is hard to find anywhere else
Hello What if I have multiple body parts like legs, weapons, accessories and I also want them to have blinking effects when the player is damaged? Everything works just fine for me but the effect only affects the body and not the body parts I've mentioned. Thanks for the help:)
Not sure if you have a chance to read this comment, but I got everything working up until the saw so far, but whenever my character touches it, the die animation plays instead of the hurt animation, checked to make sure they are all in the right place & walked through everything a few times so a little confused.
Такая замечательная серия видео. Я в восторге
Спасибо!
Man youre tutorials really got me off the ground, you have a skill for teaching it straight to the point
Hi, the code is working fine for me, but eveytime iFrames activates the animations deactivates, the anims for walking and firing, I can only loop back to normal animations when I jump. is there something I did wrong?
So, this is the paradise
Can't figure out if this is a compliment or not :D
Very cool, keep up the good work👍
Thanks! Definitely will 🙌
Out of all things that could happen, the changing of the sprite color doesn't work for me. I am not sure why. The for loop works and the enumerator works as well. I checked everything with Debug.Log and it all seems fine. It's like the animations are more dominant and will not allow a color change. (And I am not changing any colors in the animations).
The only difference is that I am using my own sprites. Do I maybe need to go with a certain setting for the sprites?
Having the same issue and I'm using the same sprites as Pandemonium.
for those who ran into a problem where the game freezes when player hits saw..... make sure you used IEnumerator and not IEnumerable at 3:22
Man I got a problem. all things are working except that my player can only get hurt once and after that it became invulnerable the saw cant hurt it anymore. please help
I'm using your code, but it seems my character still keeps taking consecutive damage. Here in the video it seems to work, but in my game the player character can be hit back to back every time it collides with an enemy or a projectile. The only thing that works are the flashes. For an example, I created an enemy that shoots three bullets in rapid succession. All of these bullets can collide with the player and the player dies instantly. Three bullets, three HP. Same happens if I walk into a trap, walk out of it and quickly walk back into it. Interestingly if you stand on top of a trap the player doesn't take further damage as long as you don't move out of it. I wonder what's causing this? I'm using your code for health, enemies, taking damage and these i-frames.
Ye, same problem here
@@lukspie Check, the Enemy and the player is in the same layer as in the video
@@minhnhathuynh5190 Ahh, that makes sense! Thank you, this info is valuable.
Still don't work for me. All layers are the same as in the video, i even copied the github script and the error "NullReferenceException: Object reference not set to an instance of an object" comes up in unity
I have a question. If I take damage with s and pause game (I made pause menu) and go back to menu and start again I don't take damage plz help
your codes are amazing thank you for good video
waiting for a new video of this series!
love this series! is there a way to make it so health auto regenerates after a certain amount of time instead of when getting collectables?
A basic timer will do the trick. Make a time variable somewhere, increase it by Time.deltaTime in the Update and when it becomes higher than X(let's say 120 seconds) increase the health and reset the timer.
Thank you so much!
Hi there,
Everything works well, but one issue. I can't figure out what the exact trigger for that is, but while and after iFrames, while moving through the shown enemy, my player falls through the ground.
Hope you'll read my issue and help ...
Correction: Figured out the problem are not the iFrames. It has something to do with the Enemy itself. I glitch through a point behind his body. What's the problem?
less goo finnaly
the player gets hit 2 times (once because the enemy attacks him and the second time because of the damage of collision wich you showed in eps 10) so he loses 2 lives before the Invincibility starts how can i fix that
Hi, i tried this video and it worked very well, except for the fact that when i respawn, i'm invulnerable forever. Help?
Tried all your code and they match perfect, player still not receiving damage from the saw and hurting/dying, any thoughts as to why this may be the case and any help would be greatly appreciated. Thanks
The Autocolmplete (Double tab) in Visual studio doesn't work for me but the code itself works just fine amazing videos!
Thank you Man My First Donation goes to you after my first income Thank you Man
Best of luck in your game dev journey!
the sprite changes happened but still not invulnerable. I copied your entire code to see if that works but no invulnerability.
same here
I cant get my player to flash when taking damage. Help?
hey, 2seconds / 3 * 2 = 1,33.
--> iFramesDuration / numberOfFlashes / 2
not iFramesDuration / numberOfFlashes * 2
Спасибо!
Thanks!!!
hi, great job, but I don't understand how to make it so that when the lives are full, they don't rise, they don't replenish
I would be very grateful if you could help me
any fix for not all codes return to value . for the ienumerator
@@AhmetBabagil. didnt work
Has anyone had any issues where after adding sorting layers, and going through the previous tutorials your player jumping and attacking animations won't play?
I have the same issue. Did you solve the problem?
I have the same problem
I have same problem
Have you solved it yet i have the same problem
I have the same exact problem
rEAlly really good content
Thank you!
i delet my minacamra but i do not how back my camre
Hi ,amezing work buddy .can you make one tutorial on how to swim under water or how to create water in unity 2d
I'll add it the list, but not in this series
How would I do the flashing if my character is made from more than one sprite?
You'll need to create an array that holds all the sprite renderers, than use a loop to flash all of them
@@PandemoniumGameDev not sure I know how to do that, but at least now I have an idea of what try. Thank you.
@@izeckx I personally used EntityRenderer instead of the SpriteRenderer class and it seemed to do the trick.
Can you make a game over tutorial?
Yes sure. I plan to make this a complete game
PLEASE Tell Me how to import projects, I got stuck at lvl 3 and I cant import it!
Go to the GitHub link of the episode you want to download and just download the zip archive. Unzip it and open it in UnityHub, should be simple. DM me on discord if you can't make it work
Start coroutine my brain:
"NO NOOOOOOOOOOOOOOO NOT AGAIN"
Why? You find it hard to understand coroutines?
I really enjoy your contents even tho im new i already enjoy some of your videos, keep on. But i cant find your video game(Dive) on play store, thats sad, cause i wanted to support
Thanks for the support 🙏 here it is: play.google.com/store/apps/details?id=com.PandemoniumGames.DiveFinal
It's not bringing in almost any revenue though, so if you like my videos just keep watching them, that helps more 😁
Please make tutorial if the enemy not see the player than the enemy shut patrol.. But if the enemy is see the player than the enemy is jump and jump.. :)
I understood that you want a patrol behavior for the enemies, but could you explain this: "than the enemy is jump and jump"?
@@PandemoniumGameDev something like that
@@jefferrr7376 like what? :D
@@PandemoniumGameDev like if the enemy see the player and the enemy shut jump and jump but if not the enemy shut patrol
@@jefferrr7376 ?
Можно какой ни будь урок по созданию игры типа Alien Shooter на пк
Давно в планах сделать что-то такое, попробую успеть в следующие 2-3 месяца.
@@PandemoniumGameDev было бы круто запилить 3д шутер с атмосферной локацией. И загрузить его в стим. Готов тебе заплатить если доведёшь меня до конечного результата. Я веб разработчик, но сейчас что-то заинтересовал геймдев
Please make a tutorial on how to collect money Unity SHOP SYSTEM Tutorial - UA-cam
Когда будет урок на русском ?
Сорри, не думаю что вообше будет. Большинство моих сабсов не знают русский.
Как ты вообше узнал что я говорю на русском? :D
@@PandemoniumGameDev акцент чувствуется ))
@@PandemoniumGameDev а я то думаю почему на русском почти нет дельных видосов по созданию игр 😂 нашлась пропажа