Couple of things to consider; While overall the thing shown works as intended - it becomes a huge pain in the rear to maintain further down the line. | > Singletons end up being a mess of it's own, where you can't really create a thing in isolation anymore. Every scene requires you to drop a prefab with all the singletons and in case you need to alter the behavior for some characters but not all - it becomes even a bigger mess > Connecting game logic (AttributesManager) to UI logic is usually a bad idea (again, if the singleton doesn't exist - damage reception code would throw exceptions) | Here's my proposition. Instead of using PopupGenerator as a singleton - use it as a component on the character gameobject near AttributesManager. Expose an event in AttributesManager [public event System.Action ReceivedDamage; //where DamageArgs can be a struct with damage value and damage type] and raise it inside TakeDamage method. So now the PopupGenerator can find AttributesManager on start, and if it exists in the same gameobject - subscribe to the event and do it's job. This way the codebase doesn't develop weird dependencies that are hard to maintain, the logic can be changed for specific characters and it's easy to further abstract this system if needed. Also, if you're worried about manually assigning the same popup prefab - load one automatically inside OnReset
Extra stuff: 1) To mitigate a singleton one can implement the service locator pattern, abstracting the CreatePopup method in a IPopupCreator interface, so that the creator can be easily swapped out for testing or blanked out with a dummy one. While not ideal, it still alleviates some of the typical singleton issues. 2) Instantiating and destroying objects all the time is not ideal. Consider Object Pooling.
Thank you for the feedback! I was expecting someone to start the discussion on the use of singletons while making this video. And yes, I agree that we need to tell beginners an easy solution and a better practice. First of all, I do agree that singletons are problematic in most cases, but there are cases where singletons can be useful. I don't avoid it like plague just because I was taught to avoid it. I believe this is one of the times where it's okay to use it, and we can argue it in this discussion. The intended system in the game is to have one generator to control them all, so I just need to have one object pooling. And the scope of the game is quite simplistic, with just one type of damage pop-up, following Genshin Impact as a reference. I can't think of a scenario where I would want to have a different logic or abstraction for the pop-ups. Maybe if you want a different animation for the pop-ups? I'm not sure. If you have any example, let me know. If the goal is to have as less dependencies as possible, then I think event system is a worse solution because it requires subscribing and unsubscribing event. If the game has a multiplayer function or an ability to mass create hundreds of enemies at once, I'm not sure if the event system will like it. But maybe this is just my own bias. I did try to use event system in the past, and it crashed my Unity. As I said, I think it has some performance issues that I haven't researched yet. So that's why I used Singleton in this video. But yours is a good feedback. Certainly, one of many ways to do it, and might be necessary in more complicated projects.
@@ReForgeMode Yup. Indie development is built on breaking coding traditions, but eventually it comes back to you. Last time i had to track a weird out-of-nowhere singleton call a store asset was making i almost vowed to never use singletons for anything xD The first thing that comes to mind to justify swapping popup logic is training dummy damage view. A popup that stays alive for a while and accumulates whatever damage was done last X seconds to a dummy, like a DPS counter, updating real-time. The same thing could work for a high-hp boss as an extra display in addition to the generic popup Huh, guess everyone picks their own poison. Never had any issues with event subscriptions, as a typical reference function call in csharp has negligibe performance impact compared to a direct call. Edit: my goal wasn't to bash on the original video, but to provide a solution to those seeking it. I remember how everyone told me certain things were bad to use, but there was no better offer presented no matter how much i tried to google an answer or ask directly xD
I do understand that you genuinely gave me some helpful feedback. If you didn't, you wouldn't spend much time explaining anything in detail. And I do appreciate it! I still have a lot to learn. Oh, that's a good point! I do remember this is how Souls game does it. The pop-up damage accumulate until either a timer expire or if the player deals more damage. I guess I wasn't thinking that far ahead, or that the scope of this tutorial is just limited to Genshin's implementation as a reference. To clarify, the last time I used an Event system, I did 4 event triggers as a part of a damage tick. To this day, I never even understand how it happened. It was just a UI testing project. Huh... I appreciate you spending time in this discussion! I think I'll pin this message so everyone can see it.
Great tutorial! One little note: 12:57 If you want the random spawn points to not only be on the right side of the parent object transform, remember to have the Random.Range values being the same in negative. Ex: Random.Range (-0.25f, 0.25f).
This video includes so many lessons. I knew many things about textmeshpro but I didn't know how to make it cover gameobjects(which can be possible by changing shaders), neither I knew it was possible to do its animation by code
Haha, glad I could teach you new things! Pro tip: you can use that overlay shader on other things as well. This is something I will abuse in later videos too.
"Something easy doesn't necessarily mean it's right". The more I make these tutorials, the more I realized how true this is. Part of the skill you need in game development is to decide which method to use, after weighing the upside and the downside. You might have read some of the comments in this video saying that this might not be the best approach for a bigger game. And I do agree. There are some cases where singleton pattern should be avoided because it creates a dependency that would be hard to manage. For example: if you want to have different kinds of pop-up damage. I knew what I signed up for when I made the script for this video. One of the core principle of game development is KISS (Keep It Simple, Stupid). If your game is a small one, then I don't think it'll hurt to use one or two Singletons in your project. And then, most of you who came to this channel came here because you want to learn how to make a game from your VRoid model, without any or little experience with Unity. So in this case, Singleton is the best approach to push your first project moving forward and your motivation high. Being stuck on hyper-optimizing your game early is a mood-killer. I've been there before. I do highly encourage everyone to check out other design patterns once you fully get this tutorial or when you're planning a bigger game. Also, check out *Object Pooling* to optimize your damage pop-up This is just a starting point for your journey in gamedev. Keep learning and keep creating 👍
I know this is from awhile ago, I got everything working, what I want to know is how to adjust the heightCurve so that the next tick of damage will always pop up above the previous tick of damage, so that when I'm doing a high speed attack it is easier to see all the numbers, as of right now they just overlap each other so its hard to see how much your doing, other than that its a great system.
I see. You can create a height variable that increases every time the Damage Popup is called. And then a timer that resets the height if the function is not called after a while. Then you can assign this height value to the Y of the instantiated popup.
what a amazing tutorial, thanks for sharing sir, can i request? like pickup or just equip armor / sword from with dynamic stats for every different item, and its calculated into player stats like increase hp, damage, etc
It used to be difficult, but right now there are so many guides for it that it gets easier. But designing a GOOD and UNIQUE 3D fighting game is always a bigger challenge. You have to do something new.
Omg, I must return to checking it all and learning! Also, could you make tutorial how to make custom (with custom animations) movement system? Free assets are great, but walking, jump style just doesn't fit what I want to achieve Once again thanks for your great content! 😃
Glad I could help! I think what you're looking for is custom animations in your character controller. You can swap the default animation with your own animation. There is no character controller that is ready to use from the get go. You'll need to adjust it according to your game. Adjust the jump height, jump distance, time in the air, double jump, etc. It takes time to get the feeling just right. Now, custom animation on the other hand, is a very difficult topic to cover. In most cases, you'll need to make your animation from scratch. Don't get me wrong. There's value in making your own custom controller. That means you'll understand exactly how it works and how to make custom modifications. But the path to make it has been covered by a lot of people more qualified than me.
I would like to know how to remove the clothing from the characters of vroid or put other clothing models that are not limited to textures. I would greatly appreciate it!
Awesome Video! Everything works but I'm wondering how to actually attach this to my enemy and have the damage number happen when my sword collides with their hitbox
Hello, which part that doesn't recognize the word prefab? If you're scripting, you need to be precise. It's case sensitive, where uppercase and lowercase matters.
I'm back! So I came back to this video to make the popup text, I'm trying to figure out how to make a critical hit have larger text, I haven't figured it out yet, I'll reply to this comment if I figure it out, but if anyone wants to help me out that's fine too.
That's because you need to add the Origin position to the AnimationCurve! By default, the Animation Curve will set all position to 0,0. When we instantiate the prefab, we take position it's supposed to be at in the Awake() function. Then, we add Origin to the position in the Update() function.
@@ReForgeMode If the matter is in the code, then I copied your code, in the DamagePopUpAnimate class I have origin in both awake and update p.s. Ok, I don't know what happened, I reloaded the project several times, then I got an error with nullreference, I removed everything related to crit in damageatribute, and everything worked. thanks anyway. I'm waiting for a video with a full combat system, as well as a video on a self-written 3rd person camera
Oh, I'm glad you managed to figure it out! Null Reference Exception error happened when you're using an unassigned variable. This is usually happened if you forget to fill a field in the inspector or if you're trying to use a variable that doesn't exist yet in script. I'm glad it helped! The next video will be about actually hitting enemies with animations
Hi! i am a student from Taiwan,and i learned alot from your videos,but now i'm stuck at something. I want to let the character to turn her body while looking users,can you help us solves this problem?
Glad I could help! For turning the body, you might want to check out Procedural Animation. Unity supported Animation Rigging plugin. I will try to make a tutorial to upgrade my previous Look At nearby object tutorial in the near future
This feels out of my range, the project I want to build has me running into problems left and right and many things I don't know. I watch so many tutorials but they feel out of my grasp aswell. I think I need to build a smaller game before this is my feeling for now.
Well, yes... A child must learn to walk before they could run. Everything must start simple. If you want, you can create each element in your game in separate project files. When you feel like it's ready, you can combine them together.
If you're talking about singletons, we can discuss its usage here. For a game like Genshin with just one type of pop-up damage, I think using singletons is the best approach. Other commenters have commented on another approach like event system to do it. Please do share your suggestion with the comment section here
Couple of things to consider;
While overall the thing shown works as intended - it becomes a huge pain in the rear to maintain further down the line.
|
> Singletons end up being a mess of it's own, where you can't really create a thing in isolation anymore. Every scene requires you to drop a prefab with all the singletons and in case you need to alter the behavior for some characters but not all - it becomes even a bigger mess
> Connecting game logic (AttributesManager) to UI logic is usually a bad idea (again, if the singleton doesn't exist - damage reception code would throw exceptions)
|
Here's my proposition.
Instead of using PopupGenerator as a singleton - use it as a component on the character gameobject near AttributesManager.
Expose an event in AttributesManager [public event System.Action ReceivedDamage; //where DamageArgs can be a struct with damage value and damage type] and raise it inside TakeDamage method. So now the PopupGenerator can find AttributesManager on start, and if it exists in the same gameobject - subscribe to the event and do it's job.
This way the codebase doesn't develop weird dependencies that are hard to maintain, the logic can be changed for specific characters and it's easy to further abstract this system if needed.
Also, if you're worried about manually assigning the same popup prefab - load one automatically inside OnReset
disclaimer : i know it's a tutorial and doing things the way they are shown is easier, but we owe it to newcomers to show better practices
Extra stuff:
1) To mitigate a singleton one can implement the service locator pattern, abstracting the CreatePopup method in a IPopupCreator interface, so that the creator can be easily swapped out for testing or blanked out with a dummy one. While not ideal, it still alleviates some of the typical singleton issues.
2) Instantiating and destroying objects all the time is not ideal. Consider Object Pooling.
Thank you for the feedback! I was expecting someone to start the discussion on the use of singletons while making this video. And yes, I agree that we need to tell beginners an easy solution and a better practice.
First of all, I do agree that singletons are problematic in most cases, but there are cases where singletons can be useful. I don't avoid it like plague just because I was taught to avoid it. I believe this is one of the times where it's okay to use it, and we can argue it in this discussion.
The intended system in the game is to have one generator to control them all, so I just need to have one object pooling. And the scope of the game is quite simplistic, with just one type of damage pop-up, following Genshin Impact as a reference.
I can't think of a scenario where I would want to have a different logic or abstraction for the pop-ups. Maybe if you want a different animation for the pop-ups? I'm not sure. If you have any example, let me know.
If the goal is to have as less dependencies as possible, then I think event system is a worse solution because it requires subscribing and unsubscribing event. If the game has a multiplayer function or an ability to mass create hundreds of enemies at once, I'm not sure if the event system will like it.
But maybe this is just my own bias. I did try to use event system in the past, and it crashed my Unity. As I said, I think it has some performance issues that I haven't researched yet. So that's why I used Singleton in this video.
But yours is a good feedback. Certainly, one of many ways to do it, and might be necessary in more complicated projects.
@@ReForgeMode
Yup. Indie development is built on breaking coding traditions, but eventually it comes back to you. Last time i had to track a weird out-of-nowhere singleton call a store asset was making i almost vowed to never use singletons for anything xD
The first thing that comes to mind to justify swapping popup logic is training dummy damage view. A popup that stays alive for a while and accumulates whatever damage was done last X seconds to a dummy, like a DPS counter, updating real-time. The same thing could work for a high-hp boss as an extra display in addition to the generic popup
Huh, guess everyone picks their own poison. Never had any issues with event subscriptions, as a typical reference function call in csharp has negligibe performance impact compared to a direct call.
Edit: my goal wasn't to bash on the original video, but to provide a solution to those seeking it. I remember how everyone told me certain things were bad to use, but there was no better offer presented no matter how much i tried to google an answer or ask directly xD
I do understand that you genuinely gave me some helpful feedback. If you didn't, you wouldn't spend much time explaining anything in detail. And I do appreciate it! I still have a lot to learn.
Oh, that's a good point! I do remember this is how Souls game does it. The pop-up damage accumulate until either a timer expire or if the player deals more damage.
I guess I wasn't thinking that far ahead, or that the scope of this tutorial is just limited to Genshin's implementation as a reference.
To clarify, the last time I used an Event system, I did 4 event triggers as a part of a damage tick. To this day, I never even understand how it happened. It was just a UI testing project. Huh...
I appreciate you spending time in this discussion! I think I'll pin this message so everyone can see it.
Best tutorial for popup text in Unity I've ever seen so far. Thanks!
Glad you enjoyed it! 😄
Great tutorial!
One little note:
12:57 If you want the random spawn points to not only be on the right side of the parent object transform, remember to have the Random.Range values being the same in negative. Ex: Random.Range (-0.25f, 0.25f).
Ah, yes of course! Thank you for the tips!
This video includes so many lessons. I knew many things about textmeshpro but I didn't know how to make it cover gameobjects(which can be possible by changing shaders), neither I knew it was possible to do its animation by code
Haha, glad I could teach you new things! Pro tip: you can use that overlay shader on other things as well. This is something I will abuse in later videos too.
"Something easy doesn't necessarily mean it's right". The more I make these tutorials, the more I realized how true this is.
Part of the skill you need in game development is to decide which method to use, after weighing the upside and the downside.
You might have read some of the comments in this video saying that this might not be the best approach for a bigger game. And I do agree. There are some cases where singleton pattern should be avoided because it creates a dependency that would be hard to manage. For example: if you want to have different kinds of pop-up damage.
I knew what I signed up for when I made the script for this video. One of the core principle of game development is KISS (Keep It Simple, Stupid). If your game is a small one, then I don't think it'll hurt to use one or two Singletons in your project.
And then, most of you who came to this channel came here because you want to learn how to make a game from your VRoid model, without any or little experience with Unity. So in this case, Singleton is the best approach to push your first project moving forward and your motivation high. Being stuck on hyper-optimizing your game early is a mood-killer. I've been there before.
I do highly encourage everyone to check out other design patterns once you fully get this tutorial or when you're planning a bigger game. Also, check out *Object Pooling* to optimize your damage pop-up This is just a starting point for your journey in gamedev.
Keep learning and keep creating 👍
Great job once again!
Thank you! Glad I could help!
I know this is from awhile ago, I got everything working, what I want to know is how to adjust the heightCurve so that the next tick of damage will always pop up above the previous tick of damage, so that when I'm doing a high speed attack it is easier to see all the numbers, as of right now they just overlap each other so its hard to see how much your doing, other than that its a great system.
I see. You can create a height variable that increases every time the Damage Popup is called. And then a timer that resets the height if the function is not called after a while.
Then you can assign this height value to the Y of the instantiated popup.
what a amazing tutorial, thanks for sharing sir, can i request? like pickup or just equip armor / sword from with dynamic stats for every different item, and its calculated into player stats like increase hp, damage, etc
Thank you! That's quite a lot actually. I will note that and add that to the things I need to do. Thanks for the suggestions!
That's good!, I have regarded 3D fighting game as the most difficult game designing.
It used to be difficult, but right now there are so many guides for it that it gets easier.
But designing a GOOD and UNIQUE 3D fighting game is always a bigger challenge. You have to do something new.
Omg, I must return to checking it all and learning!
Also, could you make tutorial how to make custom (with custom animations) movement system?
Free assets are great, but walking, jump style just doesn't fit what I want to achieve
Once again thanks for your great content! 😃
Glad I could help!
I think what you're looking for is custom animations in your character controller. You can swap the default animation with your own animation.
There is no character controller that is ready to use from the get go. You'll need to adjust it according to your game. Adjust the jump height, jump distance, time in the air, double jump, etc. It takes time to get the feeling just right.
Now, custom animation on the other hand, is a very difficult topic to cover. In most cases, you'll need to make your animation from scratch.
Don't get me wrong. There's value in making your own custom controller. That means you'll understand exactly how it works and how to make custom modifications. But the path to make it has been covered by a lot of people more qualified than me.
@@ReForgeMode I see, thank you anyway :D
I would like to know how to remove the clothing from the characters of vroid or put other clothing models that are not limited to textures. I would greatly appreciate it!
That is going to be very difficult if not impossible. The problem is the cloth physics that are animated by VRoid Studio. But I'll look into it!
Omg you saved my life
Haha, glad I could help!
Awesome Video! Everything works but I'm wondering how to actually attach this to my enemy and have the damage number happen when my sword collides with their hitbox
Thank you! You just need to attach the script as a component. If you're still confused, the project download file is in the video description.
Hi! I tried to follow the tutorial, but unity can't recognise the word 'prefab', so I can't link the prefab to the script. What could be the problem?
Hello, which part that doesn't recognize the word prefab? If you're scripting, you need to be precise. It's case sensitive, where uppercase and lowercase matters.
@@ReForgeMode Oh, I've found the problem, it was my mistake, I left out a line accidentally
@@ewellynn122 Oh, yeah that's how they get ya. Glad it works out in the end! 👍👍
I'm back! So I came back to this video to make the popup text, I'm trying to figure out how to make a critical hit have larger text, I haven't figured it out yet, I'll reply to this comment if I figure it out, but if anyone wants to help me out that's fine too.
Welcome back. You can just easily increase the scale/font size and then lower it down again using the curve.
My pop-up text spawn in one line, to be more precise, only in the middle of the map. Why?
That's because you need to add the Origin position to the AnimationCurve!
By default, the Animation Curve will set all position to 0,0. When we instantiate the prefab, we take position it's supposed to be at in the Awake() function. Then, we add Origin to the position in the Update() function.
@@ReForgeMode If the matter is in the code, then I copied your code, in the DamagePopUpAnimate class I have origin in both awake and update
p.s.
Ok, I don't know what happened, I reloaded the project several times, then I got an error with nullreference, I removed everything related to crit in damageatribute, and everything worked.
thanks anyway. I'm waiting for a video with a full combat system, as well as a video on a self-written 3rd person camera
Oh, I'm glad you managed to figure it out! Null Reference Exception error happened when you're using an unassigned variable. This is usually happened if you forget to fill a field in the inspector or if you're trying to use a variable that doesn't exist yet in script.
I'm glad it helped! The next video will be about actually hitting enemies with animations
monkey flip
Hi! i am a student from Taiwan,and i learned alot from your videos,but now i'm stuck at something.
I want to let the character to turn her body while looking users,can you help us solves this problem?
Glad I could help!
For turning the body, you might want to check out Procedural Animation. Unity supported Animation Rigging plugin.
I will try to make a tutorial to upgrade my previous Look At nearby object tutorial in the near future
@@ReForgeMode thanks you so much!!!
GG
This feels out of my range, the project I want to build has me running into problems left and right and many things I don't know. I watch so many tutorials but they feel out of my grasp aswell. I think I need to build a smaller game before this is my feeling for now.
Well, yes... A child must learn to walk before they could run. Everything must start simple.
If you want, you can create each element in your game in separate project files. When you feel like it's ready, you can combine them together.
Shoot me a message I can try help you out bro
i missed the video :(
Luckily, this is not a livestream. So you can view it at any time. Hope this will help!
@@ReForgeMode it sure will, when i'm done with my current project, even tough it's gonna take a few months :)
@@ReForgeMode Can you make a discord server for your channel ?
Oh yeah, I should really get into that, soon!
@@ReForgeMode Let me know when you get one! i'll join right away
6969 nice.
Heh ( ͡° ͜ʖ ͡°)
more bad practicies in Unity for the God of Newbie-tutorials xD
If you're talking about singletons, we can discuss its usage here. For a game like Genshin with just one type of pop-up damage, I think using singletons is the best approach. Other commenters have commented on another approach like event system to do it.
Please do share your suggestion with the comment section here