thank you dude but just an advice, speeding up some parts is a really good idea for video timing but on some parts (especially creating elements on hierarchy) are hard to catch. I stuck on the creating mask part about 5 - 6 minutes. Thank you, anyway. Great work.
I am relatively new to Unity, and I've had to stop at 0:45 to change the speed to 0.25x just to get the speed to look normal. With all due respect, why would you speed up important moments that take less than 5 seconds in real life just to save milliseconds? Leave the viewer the option to alter the speed of your video. By doing that yourself, it forces the user to stop, go back, change the speed, and play detective to figure out what they missed. I've had to replay the first and second minute of the video over five times on 0.25x because you've sped this up so quickly. The content is great. But the manner in which some of it is delivered is illogical and frankly obnoxious. Cheers.
For those that wants to use this with a healthsystem where current and max health is not between 0 and 1, you can convert those values by passing SetSize(maxHealth / currentHealth), that will normalize the value. Remember to have them as floats.
Excellent, It would be a great if bit slows down when speeding up the trivial task or put list of steps you perform in slide so absolute beginner can follow!
I couldn't understand anything because of irrational timing decisions of the video. For example, masking operation is the most important part to complete the task but eventhough I watched it in 0.25 speed hundreds of time, I still couldn't figure out the complete opreration. Boooooo
At 10:30 the video is at normal speed as I explain how all the elements are set up. You have a game object with a Mask and a Image then a child of that game object with the bar sprite.
@@CodeMonkeyUnity Yeah but for example the process which you properly put anchor points of the mask and bar is still blurry for me. It has been 3 days I am trying to understand why left anchor attached bar sprite halves when you change aspect ratio, lets say 9:16 to 16:9. You managed it somehow and shared the codes thanks for that of course. But I just wanted to make a feedback for your future works.
I mean you used stretched anchors for every other canvas object, except mask and bar. And when I change the aspect ratio, everything fits perfectly well except mask and the bar.
Finally, a good tutorial on doing progress bars with something other than the basic sprite fillAmount approach, which, as you said, is way too simplistic. Would love to see some examples of what you can do with shaders for the UI as well as more tutorials on achieving more advanced UI effects just as this one - there's definitely not a lot of it out there.
i get an error that says "There is no argument given that corresponds to the required formal parameter 'amount' of 'Mana.GetManaNormalized(int)' Can you please help me with this?
Normalized values help you use them in any scenario without knowing what the underlying min and max values are. So for example you can display the size of a Mana bar without having to know MANA_MAX. With a normalized value you can calculate whatever relative value you want.
well timed i was just making health and shield bars. question if you have multiple units how do you get the ui bars over them or should i make an ingame bar.
If you're making a game with multiple units like say a RTS I would create bars in the World instead of the UI. Otherwise you're constantly having to calculate World position into UI coordinates.
dude... cant even download the files because his website keeps telling me to validate my email when i already clicked on that link in my gmail and it said "User Already Validated"😮💨
It would work the same, Start(); get called right after Awake(); Normally I put the initialization code of an object on Awake(); and on Start(); I add whatever connections I need with other objects.
pls help how do i call the tryspendmana function from a key, like if(Input.GetKeyDown(KeyCode.T)){ mana.TrySpendMana(30); } that is my exact code, yet it does not show up that i used any. =[[[[
You can use the options in the RU-vid player to slow down or pause the video. Remember your goal is to learn, so don't worry about trying to learn as fast as possible, pause as much as you need to understand the content.
I have a doubt sir. In my game, I am having a shooting bar. Which means , If I hold the shoot button, then the shooting bar gets decreased and if the bar is at 0 then the player should stop shooting. And the shooting bar regenerates. Problem is if I press the shoot button it is decreasing but it is not stopping to shoot. It is continuously shooting after bar is at 0 while holding the button. And I solved this problem by using setactive. But after that, another problem came, that is, if I press the button, it is not shooting after the bar is 0, yeah that's fine, but the bullets are only disabled, so it is creating many disabled bullets in hierarchy. What should I do sir plz 😥😥
Hi! First of all, great tutorial, as always. Second thing: in my attack script i need to make a condition that when the mana is at 40, the player can attack. But the problem is that i can't refer the manaAmount int in my if condition, and if i try, it gives me a NullReferenceException error. Obviously i referenced the mana script in my attack script. Here's my code: if (playerController.isGrounded && Input.GetMouseButtonDown(0) && stand.activeSelf && energyAmount >= 40f) { Attack(); } Hope you can help me ;)
So the sizeDelta approach doesn't seem to be working anymore despite setting the achors to the left. It just starts resizing from the center instead so it's being squeezed instead of filled from the left. Edit: you gotta set the pivot point to 0 0 to make it work.
What part is it not for beginners? It's a very simple UI sprite, I cannot think of anything simpler. If you know the absolute basics you should have no problem following this tutorial ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-E6A4WvsDeLE.html
You should always keep your classes as decoupled as possible in order to keep your code clean to be easier to follow, understand and maintain. It also allows you to completely change how you display Mana without having to modify the underlying class at all, just change the visual.
MonoDevelop is very old and I don't think it's Unity Supported anymore, install Visual Studio Community or Visual Studio Code and install the Unity Tools.
Can this code be used simply like in the video, if the UI button "Spend Mana" is replaced by an action - say: if[canJump] { mana.TrySpendMana(20); } ? I've tried this for a while now with no results, and cannot seem to make it work. I have the mana bar in it's own script, and I'm referencing it to my movement script with Mana refScript; void Start() { refScript = GetComponent(); } Right now, when (refScript.TrySpendMana(20);) placed into the jump-function it simply states "Object reference not set to an instance of an object". Do you know what's wrong?
Mana is not a MonoBehaviour class so you cannot grab it with GetComponent(); You need to instantiate the Mana class somewhere and pass it in to your player script and also to the bar to update the visual.
@@CodeMonkeyUnity Well, it appears then that there is a solution to this mystery! However, now I'll need to figure out what you just wrote, hehe. (There is a reason I'm in a beginner tutorial here). Actually posted about this to your Discord as well, but thank you immensely for taking the time to answer me!
Thanks for this. I admit that I got hopelessly stuck around 60 seconds in. I decided to get 'basic-fancy' and import a gradient box to serve as texture in substitute for the 1x1 pixel. Unfortunately it refuses to be linked to the Image (script) component in the inspector - and (1.5 hours later) I gave up and wrote this comment. ^_^;; It does accept to be linked to a Raw Image script component - but that has none of the convenient fill elements.
With guidance the mystery has been solved! :c) The 'basic-fancy' image was imported as a raw image so all I had to do was to click the imported asset, - go to 'Texture Type' and select 'Sprite (2D and UI). Now I should be able to follow along with the tutorial properly! :cD
Question. I have made the mana system as shown and it works. I also made a dash system in another script ,from the movement tutorial. Now I want the player to dash only when there is enough mana but I cannot come up with a solution. Pls help
This is the ultimate tutorial! Worked with Unity for 5 years and still learned a thing with RawImage UV Rect and using ImageType.Filled Horizontal instead of using a Slider. Great tips!!
Stuck @ around 11 min. I've set my barMask to anchor on the left side, but when I adjust the width it still shrinks from both sides towards the centre. What I do notice is that when you modify your anchor, the blue circle denoting object origin shifts position, but mine does not. Why is that? Don't know what I'm doing differently, and everything else is working well =(
It all depends on how detailed you want your bar to be. At it's simplest form it's just one line of code to set the bar size barImage.fillAmount = barSize;
After creating the UI > Image ("background") as a child of the ManaBar, when I set the Width and Height to 0 it fails to inherit from the parent object ("ManaBar") and I'm left with an empty rectangle with no color. Do you know what I am doing wrong?
Make sure the RectTransform is set to extend on all sides. Anchor Min 0,0 and Anchor Max 1,1. When you do that and set the width and height to 0 it will extend to occupy the size of the parent.
Hey I'm not using Code Monkey so to use my mana which in my case is turbo I used this: if (Input.GetKeyDown(KeyCode.X)) turbo.TrySpendTurbo(20); But it doesn't work, also my bar starts at 0 instead of 100. Can you help me out?
If your bar isnt changing do some Debug.Log's to make sure the underlying variable is indeed being modified when you do TrySpendTurbo and make sure the bar is updating with that variable.
Terrible tutorial. No idea why you'd need to speed certain sections up so quickly. Really makes the tutorial much harder to follow. We have the option to speed to video up ourselves.
You also have the options to slow down the video and pause it when needed. This is your learning journey, its not a race, so take your time and focus on learning.
@@CodeMonkeyUnity Use your brain. Leave the video at a constant speed and it's much easier to follow/change to what speed I want. You constantly changing the speed of the video is jarring and very poor for a tutorial which is why you never see this behaviour in other tutorials. Also, read the comments. I'm not the only one complaining. The first rule about making good tutorials is to not over assume knowledge of the person watching.