Place UI Elements in your World! (Health Bar, Overlays, Timers)

Поделиться
HTML-код

Комментарии • 81

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  3 года назад +4

    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Get my Courses unitycodemonkey.com/courses or Support on Patreon www.patreon.com/unitycodemonkey

  • @Sephta
    @Sephta 3 года назад +16

    I kid you not when I say I literally was researching this topic a day before this videos release. Your timing is immaculate!

  • @MohamedMagdy-ql3pl
    @MohamedMagdy-ql3pl 3 года назад +13

    Interestingly enough, it looks like literally everyone has been looking for this yesterday. Looking forward to more UI tutorials!

  • @diogomuller8089
    @diogomuller8089 3 года назад +3

    I literally needed this right now, thank you so much!

  • @arcday4281
    @arcday4281 3 года назад

    Your channel is getting better every day ! At the expense of my obsessive theme "Ways to Reference GameObjects" I mean: hook-up, FindObjectOfType, Singleton, ScriptableObject, Dependency Injection ... I hope you will add this either in a separate video, or in the advanced" C# "in " Steam". I think it will be useful for beginners to understand your code even better. Especially the methods you use in your code. Some things were not clear to me personally. Perhaps I missed something and did not see the explanation on this topic )))

  • @pauls.7663
    @pauls.7663 3 года назад +3

    Omg. This is exactly what i need! I experimented with that yesterday! :P

  • @neozoid7009
    @neozoid7009 2 года назад

    Awesome Thanks CM again , This was a very helpful information

  • @muntasirchowdhrymridul64
    @muntasirchowdhrymridul64 3 года назад +3

    So, I was watching your video and suddenly an ad came up. Guess what! it was an ad for your own course! You got an ad for your course in your own video XD
    it's like paying yourself XD
    anyway, thanks for such an awesome video.

  • @_shon3266
    @_shon3266 3 года назад

    Great tutorial)
    I always used slider for healt bar, now i know about Fil Method in Image^^

  • @MasterBroNetwork
    @MasterBroNetwork 2 года назад +2

    Figured out my own fix for the scaling issue, I set it to Screen Space - Camera, designed the UI and then set it to World Space, it fixed the issues I had with it.

  • @omar-0082
    @omar-0082 4 месяца назад

    thank you very much its much simple that i excepted !

  • @Nick-rq4gy
    @Nick-rq4gy 3 года назад

    This is great, seen it so good.

  • @ibmagar6188
    @ibmagar6188 2 года назад

    Very awesome tutorial

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  3 года назад +6

    💬 Here's a simple video on a very useful feature.
    For example I used this in making my recent Racing RTS for making all the UI in the game on top of the Player's car.

  • @jean-michel.houbre
    @jean-michel.houbre 3 года назад

    Nice video, thanks.

  • @leonardo6631
    @leonardo6631 3 года назад

    Great video!

  • @nyscersul42
    @nyscersul42 2 года назад

    Helpful!

  • @tauheedgamedev2388
    @tauheedgamedev2388 3 года назад +1

    Im one step closer to building my dream RTS game.

  • @djm754
    @djm754 3 года назад

    Hello there, I'm having issues with world space canvas rendering. It's in a 3D game and it's rendering on top of everything. It's supposed to just be on a screen but when I leave the room it shows through everything. Can't think of anything to do to fix this, aside from not using UI materials. Any help?

  • @RaulKFernandes
    @RaulKFernandes Год назад

    Hey there, nice approach on this! I was trying to replicate all that for a test but on my world space canvas sorting layer there was no "Top" or other options then "Default". I need to implement an onboarding where a 'hand' UI Image appears in world space to animate between two positions in a loop, but also to render in front of the other objects. That "Top" sorting layer would cover this? How did u set it? If not, do u know another way that i could implement this approach? Anyways, thanks for you content :)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад +1

      You can create as many sorting layers as you want and order them unitycodemonkey.com/video.php?v=5_BwFB-1dAo

  • @kennysrael2288
    @kennysrael2288 3 года назад

    I think sprite objects has polygons in it, when you look at wireframe mode, so maybe that affects the performance. I'm not 100% sure thougb

  • @leonardocafissi5580
    @leonardocafissi5580 Месяц назад

    I have a problem, I have to create a smart glasses, I want to show ui wordspace of some people only in the glass of the glasses, I try to use sprite mask (but it works only with objects not with ui element) or ui mask (but it hides only the children of ui element with this component), how can I do this? sorry for my bad english

  • @mrzaphkielYT
    @mrzaphkielYT 3 месяца назад

    So i already implemented a WorldSpace health bar for my enemies. How can i reveal their position?
    I just want to display a small icon above their head and i want that icon to not be blocked by GameObjects. It's kidna like a "object marker" thing which always visible regarding from the distance.

  • @matthiasVO
    @matthiasVO 3 года назад +1

    You should make a tuturial on how to make your game multiplayer. (mobile) would really help me out

  • @vijayathaker552
    @vijayathaker552 3 года назад +1

    Sir I need some serious help in unity 3d health bar. I made health bars for enemy in unity 3d working perfect but the problem is with the size. Suppose I am looking at the enemy from a point and the health bar looks perfect but when the enemy comes near me the health bar size grows, I want to do something from which the health bar seems to just move and not getting larger on coming near the camera. I want it to look like its floating there but while coming near the camera its size increase and going away decrease. Can anyone help me if u understood?

  • @sundarakrishnann8242
    @sundarakrishnann8242 3 года назад +1

    Hi in the prefab editing mode the prefab is bright and looks as expected but on dragging the prefab model in to the 3d scene it becomes too dull! I think it is because of the lighting? Is that the only reason or is there anything else? Also one part of the model is darker than the other mostly due to lighting, could you please make some videos on 3d lighting and polishing the scene, I dont know anything about lighting....Also please suggest some quick tips and things that I have to follow to have a good lighting! Thanks !

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад +1

      In Prefab editing mode I think the lighting is essentially unlit, so it gets light from everywhere.
      On the actual scene it depends on your directional light and any others you have.
      Lighting is definitely a very tricky subject, you just have to keep iterating and playing with all parameters. Change the intensity, color, ambient light, baking settings, etc.

    • @sundarakrishnann8242
      @sundarakrishnann8242 3 года назад +1

      @@CodeMonkeyUnity oh okay! Thanks a lot! I shall look into it and play with the values!

  • @manhleuc8199
    @manhleuc8199 4 месяца назад

    I try to create a 2d game and use Y axis transparency sort mode, when i add health bar UI in my character their pivot are dissimilar, sorting group can't group UI elements like other gameobjects. Can you help me?

  • @samirkazah302
    @samirkazah302 3 года назад

    Highly underrated feature

  • @wendten2
    @wendten2 3 года назад +1

    in 3D, if you want your world space canvas to have a 2D look (looking at the camera) how do you achieve that? doing the rotation in the update seems a bit bad performance wise

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад +4

      You do have to rotate as much as your camera moves so probably on every Update
      It's just a simple script on the Canvas with a transform.LookAt(cameraTransform.position);
      That's a pretty fast operation so it's unlikely to end up as a performance issue.

    • @RecOgMission
      @RecOgMission 2 года назад

      I've used this. I create UI elements on the canvas and, in my camera controller, I call the rotation method whenever the camera rotates, instead of each frame. I also resize the UI elements based on camera zoom, so they are still visible when zoomed way out, and shrink to not take over the screen when zooming in.

  • @QvsTheWorld
    @QvsTheWorld 3 года назад

    I have 2 question. How would I manage the rotation so that le ui element is always facing the camera straight on. Secondly in the case of the wall I would always want the health bar to be between the wall and the camera and still shrink from view while walking away.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад +1

      You can make a simple script that just does transform.LookAt(cameraTransform.position);
      If you always want it on top then you can use layers and a custom render objects feature

  • @hondayadav9527
    @hondayadav9527 3 года назад

    awesome

  • @UnRATel
    @UnRATel 4 месяца назад

    i am currently trying to add Damage Popups to my spawned Monster (i already watched your other video about Damage Popup) my problem is that i am using Screen Space - Overlay for my project and i can't get it done spawning these when they get damage right above their head (with animations). If i got that right for UI i need to use "TextMeshPro - Text (UI)" and this inside a Canvas. I instantiate the DamagePopup with the same Transform as the Monster and additionally set my MainCanvas as parent (so it gets spawned inside)... but this doesn't really seem to work :/ hope for help

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 месяца назад

      Not sure I understand your question, your main Canvas can indeed be Screen Space Overlay, and then for the damage popups you can put each of them inside a Canvas and make it World Space, then position that canvas wherever you want

  • @erickpeculiar823
    @erickpeculiar823 10 месяцев назад

    ty. I was confused as to why text always spawned with Canvases.

  • @DjCtavia
    @DjCtavia 3 года назад

    Lovely accent, nice tut.!

  • @rlhugh
    @rlhugh Год назад

    How to handle text? Appears hard to scale. I can get text to show correctly scaled using 'scale' on the text, but seems messy. Wondering if there is a standard solution for this? (scale the canvas perhaps?)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад +1

      You can indeed play around with the scale, either the Text object itself or the Canvas. Although personally I normally tend to modify the text font instead.

  • @L1ghtOn3
    @L1ghtOn3 Год назад

    My UI Keeps getting cut off behind the terrain, any ideas to bring the UI in front of the terrain, it looks terrible when playing and the controls which are touch get lost as well depending on which side I pan when looking around, you would think unity would have the UI in front of everything? Thank you

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад

      If you want the UI on top of everything then use a regular Screen Space canvas, not a World Space canvas.
      The World Space canvas is exactly meant for it to be occluded by world objects in front of it.

    • @L1ghtOn3
      @L1ghtOn3 Год назад

      @@CodeMonkeyUnity I have my canvas on screen space camera. I fixed it by puting the plane distance from 1 to 0.25, my pause menu to 0.25 abd ny gameover canvas to to 0.24, The main UI with my all my UI like health and rouch controls works from 0.23 - 0.26 anything higher it starts to move behind the terrain. I feel 0.25 is fine, I need the GameOver to cover the main UI so it goes to 0.24 and the Pause menu works on 0.25, I thought about 0.24 but tangles with the GO canvas, bizzare, still woking all this iut since its on screen space canera, not overlay or world. So far so good, really did not like the UI health etc disappearing behind the terrain at times but works now yipee, thanks for the reply and maybe ive helped someone else? Who knows. Cheers ✌

  • @pedravoadora2230
    @pedravoadora2230 2 года назад

    There is only one thing that i still can't make work. I can't make texts small enough, the font size cannot go below 1. Do you have any ideas on how to do it? Thanks!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      Interesting, I've never tried going under 1 but I assumed it would work
      I guess you can maybe play with the scale, put the canvas scale on something like .1, .1, .1 or maybe the text object itself

  • @bhautikranpara7664
    @bhautikranpara7664 3 года назад

    sir there is only one tutorial of autoverb in unity so plz make video on it with detail as you are making in your every videos

  • @omiorahman6283
    @omiorahman6283 3 года назад

    It looks attractive

  • @FractalIND
    @FractalIND 2 года назад

    do you wknow a way to make the UI overly in 3D, ik i can use worldtoscreenpoint, but i need the scale so hat it looks like i am getting farther or closer

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      Using this world space canvas is how you do it, it's an object in the world so as you move in it gets bigger, what else do you need? How to interact with it? I covered that Cyberpunk Remake video for interacting with an ATM ruclips.net/video/pIzWlfbVORU/видео.html

    • @FractalIND
      @FractalIND 2 года назад

      @@CodeMonkeyUnity i wanted to make the 3D Ui in the canvas to be on top of everything, i figured it out

    • @jz3r073
      @jz3r073 2 года назад

      @@FractalIND how

    • @FractalIND
      @FractalIND 2 года назад

      @@jz3r073 i dont think i have the project anymore, ill look in the morning cuz its like 2 AM 🙃

    • @jz3r073
      @jz3r073 2 года назад

      @@FractalIND bro, thanks so much, but I finally figured out, no problem my men, go to sleep hahaha

  • @mechworriorsmasterstreams6608
    @mechworriorsmasterstreams6608 3 года назад

    Please sir make tutorial on c## language too.

  • @TheYuuuk
    @TheYuuuk 3 года назад

    Can you to teach how to render 3D models (can rotate) in UI Elements?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      Hmm I think if you just position the object on the UI layer as a child of the Canvas
      Or make the UI with a Camera instead of Screen Space and it should work

  • @ryanyuri980
    @ryanyuri980 3 года назад

    Make a collab with Josh of Let's Game It Out, please

  • @AnAn-nh9nd
    @AnAn-nh9nd 3 года назад

    can you make a level unlocking system tut?
    or u already made 1

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      Not sure what you mean by that, I made a Level System ruclips.net/video/kKCLMvsgAR0/видео.html

    • @AnAn-nh9nd
      @AnAn-nh9nd 3 года назад

      @@CodeMonkeyUnity like when you complete a level(aka a stage) it unlocks a new one

  • @redoctober2088
    @redoctober2088 2 года назад

    My 2D player rotates. How do I freeze the health bar rotation, so it's always above the player?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      Add a simple script to set the transform.eulerAngles to 0,0,0 on LateUpdate

    • @redoctober2088
      @redoctober2088 2 года назад

      @@CodeMonkeyUnity Okay, thank you!

  • @GRAVITONIX
    @GRAVITONIX 3 года назад

    Nicee

  • @halivudestevez2
    @halivudestevez2 4 месяца назад

    how to make the canvas look towards the camera?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 месяца назад +1

      Easiest way is just make a simple script that does transform.LookAt(Camera.main.transform);
      Alternatively transform.forward = Camera.main.transform.forward; or transform.forward = -Camera.main.transform.forward;

    • @halivudestevez2
      @halivudestevez2 4 месяца назад

      thank you for the answer! (I've also found a Look at constraint, ready-made component by unity, when I tried to add mine)

  • @Deadwindshadow
    @Deadwindshadow 3 года назад

    I use sliders for health ;)

  • @saniks5070
    @saniks5070 Год назад

    sos god

  • @d1kiyWoLF
    @d1kiyWoLF Год назад

    Guys, what if i need to press a button in the world space? I cant press it at all

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад

      You can do a Raycast yourself, I made interactable UI buttons here unitycodemonkey.com/video.php?v=pIzWlfbVORU

  • @iwoMalki
    @iwoMalki 3 года назад

    I want to be your padawan....

  • @Stnaire
    @Stnaire 2 месяца назад

    So you create a canvas for each unit? Seems really inefficient.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 месяца назад

      It all depends on your use case. Perfect fine if you have a dozen, not fine if you need thousands.

  • @AgastyaWrites1
    @AgastyaWrites1 3 года назад

    Hi

  • @RahimiaFans
    @RahimiaFans Год назад

    try make the video for beginner. i dont like your approach