Show AI Health Above Head | Floating Widget | Improved - Unreal Engine 4 Tutorial

  Рет қаралды 57,407

Matt Aspland

Matt Aspland

Күн бұрын

Пікірлер: 118
@chrisfurlong4908
@chrisfurlong4908 3 жыл бұрын
Watched your first AI health bar tutorial and glad you updated. This was great thanks!!
@sofreshprod
@sofreshprod 2 жыл бұрын
thank you so much, it's working pretty well but for the widget visibility, i prefer using a "get distance to" than an overlap box, it's safer for games. any way thank you for your tutorial, it's simple and easy to understand
@leolovehouse6565
@leolovehouse6565 2 жыл бұрын
I was getting an infinite loop from my widget if anyone else gets something like that you can always change your tick interval from 0 to 1 on your sphere and .2 on your widget
@AlexMartinez-pf7ro
@AlexMartinez-pf7ro 3 жыл бұрын
Dude thank you very much, I looked around and found a LOT of videos with repeated information that was not useful in my case, they were all casting from the Widget To the actor which was not usefull as I wanted to create a widget that displayed a countdown timer, your method casting from the actor to the widget is the correct way and it works perfecly, thank you!
@theJellerShow
@theJellerShow 3 жыл бұрын
THANK YOUUUUUUUUUUUUU OMG. I have been trying to get my same BP AI characters to have individual health bars forever! Thanks so much
@MattAspland
@MattAspland 3 жыл бұрын
Happy to help man! Wishing you all the best with your project! :)
@MZONE3D
@MZONE3D Жыл бұрын
Key Timestamps 2:15 Create AI Health HUD 2:51 Create Health Bar Binding 3:49 Add and Edit widget to AI Character 4:44 Add widget visibility sphere 5:26 Begin Play Cast and widget reference 6:22 Edit Widget Visibility 7:36 Communicate Health to Health HUD 8:15 Connect AI Health Variable to HUD Health Variable
@S2DIO6253
@S2DIO6253 Жыл бұрын
Thanks bro
@yazzindev
@yazzindev 2 жыл бұрын
Thank you very much. Changed a bit to get it working with a HealthComponent but now it's working great!
@doomgriever
@doomgriever 2 жыл бұрын
Thank you 5:30 solved my problem. Was driving me crazy not managing to Cast to the Widget class.
@tazz1226
@tazz1226 2 жыл бұрын
if on 2d dont forget to disable collision on the "WIDGET" on the viewport of the enemy, this fixed everything for me
@Your-Average-Joe-96
@Your-Average-Joe-96 2 жыл бұрын
Amazing video, I only have one probem. When i have the sphere collision on for the widget to show when your close, im unable to deal any damage but as soon as i remove it, i can deal damage again... any and all suggestion??
@conkerthesquirrel4331
@conkerthesquirrel4331 2 жыл бұрын
Thank you for all your videos, Matt. Awesome stuff.
@kazmack9968
@kazmack9968 Жыл бұрын
This was a great tutorial to setup! Just one question: How do I get the widget to constantly face the player? 🤔
@stevenwynn819
@stevenwynn819 3 жыл бұрын
Thanks for updating this tutorial. Very helpful.
@EzXet
@EzXet Жыл бұрын
Thank you very much dude! I subscribed!
@MattAspland
@MattAspland Жыл бұрын
Thanks for the sub!
@offirbaruch7895
@offirbaruch7895 Жыл бұрын
As they say in my country: "You my friend are a cannon!" (It means you're awesome!)
@MattAspland
@MattAspland Жыл бұрын
Thank you!
@thepolyglotprogrammer
@thepolyglotprogrammer 2 жыл бұрын
Thanks for the video! Super helpful!
@garic4
@garic4 3 жыл бұрын
Hello @Matt, first of all , thank you for the great video. I would really appreciate if you could give me an brief explanation on your solution here. It seems to me that you chose to update your health widget every time your health is affected, correct? (8:40) Is there any way to set up a Health Widget Component that would natively grab their owner's health variable? thank you in advance, and once again, great job with your videos
@DylonDylonDylon
@DylonDylonDylon 2 жыл бұрын
Sick! Easy and quick! Thank you very much!
@szeby33
@szeby33 2 жыл бұрын
A good idea of video would be to show ai health on aim ..or cursor over ;)
@aufgespielt3768
@aufgespielt3768 Жыл бұрын
Hey Matt! Any Ideas how to auto adjust the Z Axis from the Widget to stay always on top of the Actor on different Mesh Sizes? Thanks!
@alexjr977
@alexjr977 3 жыл бұрын
Happy Holi :) , Today is Holi in India on "28" God may fulfill your and whole world`s all wishes ✨
@MattAspland
@MattAspland 3 жыл бұрын
Happy Holi friend! Thank you for your kind words and wishes, and I wish you all the best in life!! :)
@mattmcduhhh
@mattmcduhhh 3 жыл бұрын
This was a big help for me, Thank You!
@fleurbird
@fleurbird 3 жыл бұрын
Big improvement indeed
@MattAspland
@MattAspland 3 жыл бұрын
Thanks a lot Fleur! A well overdue fix :)
@mustafa.celiktas
@mustafa.celiktas 2 жыл бұрын
Thank you so much. You are great!
@pickard1988
@pickard1988 2 жыл бұрын
Perfect :)
@KratonWolf
@KratonWolf 2 жыл бұрын
I've been using a Sprite for the same thing, but just realized how much easier a widget progress bar would be, because I no longer have to worry about if it's somehow changing it's rotation when the sprite character rotates (I'm doing a 2d beat-em-up game). I am having a bit of trouble converting from the code I had created for the sprite health bar to the widget though.
@Udara1801
@Udara1801 3 жыл бұрын
Thanks matt 😎❄️
@MattAspland
@MattAspland 3 жыл бұрын
No problem bro!
@conservativesuperlative2063
@conservativesuperlative2063 3 жыл бұрын
Gained a sub from me my friend. It was way too hard to find a tutorial accurately describing how to cast to an actor other than your player character. Simple, but hey, if I wasn't a novice I wouldn't be learning from youtube videos right? Much appreciated.
@Noyssu
@Noyssu 11 ай бұрын
Is it not too expensive to put a cast node right after every "begin" and "end" overlap event?
@andrewsoundtrack
@andrewsoundtrack 2 жыл бұрын
I followed the tutorial step by step but the bar is not reducing, like the binding not responding. I double checked everything, the bp are okay, the numbers are okay, the references are okay...I even tested with prints that the output number on the enemy widget is correct ( between 0 and 1) and its all fine, but for some reason the progress bar is not moving at all, like just ignoring the binding. Idk whats happening please help.
@scottlee38
@scottlee38 3 жыл бұрын
This looks great!
@MattAspland
@MattAspland 3 жыл бұрын
Cheers Scott, glad you like it! :)
@srandista11nuda59
@srandista11nuda59 2 жыл бұрын
Lifesaver thank you
@bloghoarder
@bloghoarder 2 жыл бұрын
Thank you! Keep up the great work👍
@Noey145
@Noey145 3 жыл бұрын
at 5:25, where does that SET come from?Nevermind, he promoted it from a variable as seen on 5:44
@dawnrigel4255
@dawnrigel4255 3 жыл бұрын
Does changing a collision's scale do anything different than changing the radius? I've always used radius to adjust the size, so I'm curious.
@RandomDude00001
@RandomDude00001 2 жыл бұрын
I wish This work for your AI punching tutorial
@Gaelrenaultdu06
@Gaelrenaultdu06 3 жыл бұрын
Hey, thanks for your videos ! I was wondering if it's possible to make a connexion between this video and the one showing how to make bars fade. Is it possible for the ennemies HP bars to become visible by fading? Thanks.
@hossam_nowiser
@hossam_nowiser 3 жыл бұрын
Great tutorial thank you
@foxy3dworld994
@foxy3dworld994 Жыл бұрын
Hello, quick question so am making an IA companion and i want it to have a health and damage system too. I want to do the same things but without adding the widget above the character... how do i go about it? 😊
@lucarionite6538
@lucarionite6538 2 жыл бұрын
I'm following your tutorials and my health code looks different than yours. When did you change this??
@Faizy_Writes
@Faizy_Writes 3 жыл бұрын
Amazing Ai_Ui
@MattAspland
@MattAspland 3 жыл бұрын
Thank you mate!
@chopstigdev
@chopstigdev 3 жыл бұрын
Thanks really cool 👌
@MattAspland
@MattAspland 3 жыл бұрын
Thanks mate, happy to help!
@MartinCraster
@MartinCraster 9 ай бұрын
Is there a way to stop the health bar scaling based on distance to the pawn?
@Shortsmanual
@Shortsmanual 3 жыл бұрын
Thanks man
@MattAspland
@MattAspland 3 жыл бұрын
No problem mate!
@AlyrioNeto
@AlyrioNeto 3 жыл бұрын
THANK YOUUUUUU
@richardalex4834
@richardalex4834 3 жыл бұрын
Hey if u only use to size screen (no disapier hud code) and for example u zoom out the hud gets scaled up. Do u know how to fix that?
@ahouraahvar2363
@ahouraahvar2363 2 жыл бұрын
this works just fine. but how can we cast to the ai controller from the widget class to get the hp directly. without the need to couple the ai hp with the widget hp and just let the widget set if for itself. i tried casting from the widget class but i cant find the right way of accessing the ai controller.
@incenseman6650
@incenseman6650 3 жыл бұрын
I followed this tut to the letter. Got an error about the return node. The health bar does not show ingame as the color I set it to. The IA dies first shot that hits it and it should not. Is there something that you might have done before you started the tut that might different? Any advice would be appreciated.
@DreamingInSlowMotion
@DreamingInSlowMotion 2 жыл бұрын
When I add the sphere collision to change the visibility, my combat doesn't work anymore. The combat works if I turn the collision type on the sphere to none, but then the visibility change doesn't work. Any ideas?
@MrE-
@MrE- Жыл бұрын
The sphere collision caused overlap issues for me (how I damage my player) so I used Get Distance To player character , to display the widget, can create a looping timer at the start or use event tick
@megtwin
@megtwin 2 жыл бұрын
Matt, I followed your animal AI series, and added this to it but when I get within the sphere and the health bar shows the AI stops its movement. Any ideas why this might be? EDITED: I found out I can't do this this way so I had to delete it. Bummer.
@Leomerya12
@Leomerya12 Жыл бұрын
It is possible, but (as of 9 months ago) your experience was limited. I imagine by now you can solve your past issue.
@megtwin
@megtwin Жыл бұрын
@@Leomerya12 At the time I had made modifications to my project, I'm I probably did get it figured out but have since, like an idiot, deleted that project. lol Bad habit of mine!
@Grumpius
@Grumpius 3 жыл бұрын
Thanks :D
@MattAspland
@MattAspland 3 жыл бұрын
No problem mate :)
@Mrkev217
@Mrkev217 3 жыл бұрын
thanks
@MattAspland
@MattAspland 3 жыл бұрын
Always a pleasure :)
@Laura-qo9cc
@Laura-qo9cc 2 жыл бұрын
Been trying to find a tutorial for almost this, but - I want when I click an enemy, it acts as "selecting" that enemy as my target (So i could eventually do damage to only that actor, and only see that actors health), and my UI displays their current health in a predetermined location. I already have left/mouse displayable on the screen and everything. In so many words, I'm looking for a system similar to WoW or early MMO's where you can click an enemy, it's your target, and you can see its health in a healthbar. Any advice on setting this one up? Thx!~
@BornStellar-yp5st
@BornStellar-yp5st 2 жыл бұрын
Use a radial linetrace based from your camera's position and rotation. If the linetrace hits the enemy actor; have their healthbar become visible for a short while. PrismaticaDev has a tutorial to do this exact thing so he could show us himself interacting with his environment without actually "playing" in it.
@resproject1731
@resproject1731 2 жыл бұрын
Merci !!!!
@Grand-warden
@Grand-warden 3 жыл бұрын
Can you make the show your teammate's health bar on the screen? Multiplayer 🙏
@MattAspland
@MattAspland 3 жыл бұрын
Hi mate, you should be able to use the same method for teammates health. Display their health bar above their head when the player is close enough :)
@christianbellamy8726
@christianbellamy8726 Жыл бұрын
Tried to do this for VR and it ended up floating in front of the players vision, still moving, but floating in front of the player rather than above the target. Did I follow a step incorrectly or is this method not useable for VR? I can give more info if someone can help, just not sure if it isnt useable to begin with for VR
@RprtBak
@RprtBak 2 жыл бұрын
This only works if the widget is set to world space (For me anyway), when its on world... It works. But when I set it to screen, it doesn't. So weird....
@chipolatajones6358
@chipolatajones6358 3 жыл бұрын
I was wondering if the following is possible?, using this "Floating widget" is great, but I need a way to have it fixed so that when the camera pans left/right/up/down from the character the widget doesn't move in 3d space (becoming misaligned to the character, based on camera position) But remains aligned above the characters head in exactly the same position regardless of camera position.
@MrMininja
@MrMininja 3 жыл бұрын
I had that issue too, turns out it was just how i had anchored the widget. If you make sure it is pinned to the middle and have resized your canvas then it should stick to the middle of where you place it on your AI
@metri0n
@metri0n 3 жыл бұрын
@@MrMininja This fixed it for me. Sorta... It still looks all big if you are far away from the widget. Any reason for this?
@MrMininja
@MrMininja 3 жыл бұрын
@@metri0n the solution I had was to make them only show up at a certain distance so they didn't get too big. Not sure how they can have a set size unfortunately
@RandomDude00001
@RandomDude00001 2 жыл бұрын
And why every time i punch it doesnt work no damage why is that then when I dlete the code it work again
@sealduck2739
@sealduck2739 3 жыл бұрын
i need some help, it works but it acts like a massive hit box(probably my fault)
@joker-jd3jd
@joker-jd3jd 3 жыл бұрын
Do you know how to make a character joystick
@MattAspland
@MattAspland 3 жыл бұрын
Hey mate, if I'm understanding you correctly, you can use joystick for controls in by setting it in the project settings, and axis movements. Change the keybinds you want to use :)
@mugundhan0689
@mugundhan0689 3 жыл бұрын
iam able to cast healthbars to diiferent ai,but am unable to reduce the health.The health deduction part in my game is done in C++ code and not in blueprint.So iam stuck at updating the health values.Could you Help?
@koamoch658
@koamoch658 3 жыл бұрын
why it doesn't show in mobile preview do you know how to fix it thank you
@RandomDude00001
@RandomDude00001 2 жыл бұрын
Sory my bad it should be promoted to variable hehe
@caillustration
@caillustration 3 жыл бұрын
that was great but I the healthbar shows as empty, please help
@AmjadAli-zx7tl
@AmjadAli-zx7tl 3 жыл бұрын
It works fine but after i get close to my ai it disappears. plz help plz
@fufuxixi4495
@fufuxixi4495 Жыл бұрын
A Larissa Manuela, melou a batata no milkshake, mas, n comeu kkkkkkk
@DragonFang253D
@DragonFang253D 2 жыл бұрын
When I try to do this process for my AI, when multicasted I get the Accessed none error. Does anybody have any ideas on that?
@mrpaz410
@mrpaz410 2 жыл бұрын
Hi matt, when i add a widget class inside the BP it doesn't show, im trying to add text and not a bar however, is there an issue with text, and yes i have added the class thanks in advance :)
@mrpaz410
@mrpaz410 2 жыл бұрын
Found it, had to anchor it to the middle , thanks alot!
@dorondavid4698
@dorondavid4698 2 жыл бұрын
@@mrpaz410 Had the same problem, thanks for posting your fix...I wonder why it only works when centered though?
@mrpaz410
@mrpaz410 2 жыл бұрын
@@dorondavid4698 because the widget that renders (say the widget size in the BP is 500*500, you could find the option to make it bigger somewhere in the settings of the widget inside the BP) it will show 500*500 from the anchor, but since our widget is in the middle, which is more than 500*500 it will be out of the border and not render, you could draw to size, but i think it loses quality and has performance issues if this didn't make sense, you can contact me on discord! :)
@dorondavid4698
@dorondavid4698 2 жыл бұрын
@@mrpaz410 yeah that makes sense, thanks!
@mrpaz410
@mrpaz410 2 жыл бұрын
@@dorondavid4698 No problem
@skouro31
@skouro31 3 жыл бұрын
My HealthBar starts empty but when i damage enemy it works fine. Any ideas on how to fix it?
@it_rooster
@it_rooster 3 жыл бұрын
in the UMG component (The widget that you made for your healthbar) set the starting value to 1 for the bar progress.
@Luminosus2012
@Luminosus2012 2 жыл бұрын
@@it_rooster does not work, greyed out:/ same error like sakis
@iladiani
@iladiani 2 жыл бұрын
Does this not work if the Health value is a Float? i followed virtus's tutorial for the AI and when i combine it with this for the decreasing the ai health widget it dosent work :( please help ...
@dreadtrain2846
@dreadtrain2846 2 жыл бұрын
I wouldn't follow this anyway. It's "coded" terribly. Use it if you want an unoptimized piece of crap for a game as well as how to learn bad practices so you can continue failing in the future! This goes for basically all his video's. Unfortunately it's not just him, many youtube "teachers" are trash.
@dreadtrain2846
@dreadtrain2846 2 жыл бұрын
Also, Virtus is another one of "those" guys.
@acrux2061
@acrux2061 2 жыл бұрын
what kind of object type is this ! (i mean the name ^_^), dude?
@miauuuauLP
@miauuuauLP 2 жыл бұрын
Hey, just wanted to put the really weird behaviour I get out there and maybe someone has encountered it. I followed this tutorial along quite a while ago and didn't have any problem with it. I updated my getpercent function so that it always gets the right number between 0-1 depending on the ratio between the current and the max health of an enemy. The weird part: If I go over a certain number of HP, the healthbar only updates once the enemy has been hit a certain amount of times (with 200 hp its the 6th hit that shows up, with 100 its the 3rd). I have tried out a bunch of settings and the only thing that seems to resolve this problem is when I set the UI space to screen, which is not what I need at all. I have seen a post of someone else who had fixed this issue with just resetting the x scaling of the healthbar back to his original state, though this did not change anything for me. If anyone has encountered something similar and found a solution, please help. If you encountered it and didn't find a solution, maybe let me know anyways.
@PsyCoCinematics
@PsyCoCinematics 2 жыл бұрын
Similar issue, I don't have mine setup with Binds but a looping timer, but followed this to see how to get the widget to appear without plastering it on the player's screen. Anyway, if I set it to Screen on the component, it works perfectly, but it freaks out when set to World. Screen does it as designed, 0-100% no issue. But the moment I swap it to World it doesn't update until it should be about 45% and then appears full when about 95%. I'm currently going back and following him exactly to see if I can replicate where the oddity stems from, but I can say right off the bat, when he adds the healthbar to the actor it shows it partially filled. Mine did not from the get-go. Again, I didn't use Binds so that might be part of it. Edit: Seems to be tied to the Anchor aspect, the location of it specifically. Top left corner and it insta-fills, Center and takes about half to start showing up. Strange. Workin' on a fix. Edit 2: Well, here goes: If you scale the progress bar up to the entire canvas size, then anchor it to not the center, but the biggest option on the very bottom left (looks like a massive square) then it works fine with the World space option. But the widget will be massive. So, go to the actor's Widget component and scale down the Y and Z until it looks about the actual size you'd like to see in-game.
@miauuuauLP
@miauuuauLP 2 жыл бұрын
@@PsyCoCinematics epic 🙏🏼 if I ever go back to game dev this will help greatly
@PsyCoCinematics
@PsyCoCinematics 2 жыл бұрын
@@miauuuauLP
@miauuuauLP
@miauuuauLP 2 жыл бұрын
@@PsyCoCinematics yezziirrrr :)
@PsyCoCinematics
@PsyCoCinematics 2 жыл бұрын
@@miauuuauLP My appreciation is immeasurable and my day has been made.
@jd-foo
@jd-foo Жыл бұрын
You are calculating the bar percent wrongly, it only works here because you are using a value of 100. You actually need to bring the MaxHealth value to the equation, the you can simply divide the CurrentHealth by it.
@kingades1013
@kingades1013 2 жыл бұрын
3:16 8:42
@troyhayder6986
@troyhayder6986 Жыл бұрын
Unfortunately that's kindof what most Devs do...but if you use planes and transparency instead of umg or even static meshes or skeletal...you can have any type of health bar you want...it's a bit dissapointing...I mean it never gets any love and it's a mainstay of gaming...
@impavidusstudios1286
@impavidusstudios1286 3 жыл бұрын
WHY DOES ONLY ONE AI TAKE DAMAGE. YO I am so lost. I want multiple AI, did you just duplicate the same actor in your scene?? Or are they child classes? Mine is setup practically the same with a single health variable but if i place multiple they all take damage. I have looked EVERYWHERE to try and find a tutorial of setting up multiple enemies but I can't find it anywhere. Is this super simple and I'm just dumb or what? Ughhh
@metri0n
@metri0n 3 жыл бұрын
You will prolly need to create a separate actor. When you duplicate, you are creating childs with the original actor being the parent. I was running into this issue as well.
@applejetgg
@applejetgg 3 жыл бұрын
hey can you please help me it's very urgent i am new in game devloping i am using unreal engine 4 i have a big issue in which i want that different types of actor has to damage my charatcter i tried to do it with on component hit but i can't do it with two charcter when i connect on component hit with cast to second actor , cast to first actor disconnect plzz help me😭😭😭😭 make a video on i
@MattAspland
@MattAspland 3 жыл бұрын
Hi, out of the cast failed of the first cast you can go into the second cast. Or don't have a cast at all, then it will search for any actor. Hope this helps :)
@dreadtrain2846
@dreadtrain2846 2 жыл бұрын
Binding is so bad here my man.
@GameDevAraz
@GameDevAraz 3 жыл бұрын
Didn't Even Work, Einstein
How To Make A Health Bar In Unreal Engine 5
15:19
Matt Aspland
Рет қаралды 81 М.
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 105 МЛН
MAGIC TIME ​⁠@Whoispelagheya
00:28
MasomkaMagic
Рет қаралды 38 МЛН
СОБАКА ВЕРНУЛА ТАБАЛАПКИ😱#shorts
00:25
INNA SERG
Рет қаралды 3,1 МЛН
Making pop rocks from scratch (is complicated)
29:42
NileBlue
Рет қаралды 3 МЛН
Enemy Horde Wave System - Unreal Engine Tutorial
16:56
Matt Aspland
Рет қаралды 43 М.
Character Select From Main Menu - Unreal Engine 4 Tutorial
16:19
Matt Aspland
Рет қаралды 44 М.
AI Boxing Got me Wheezing
15:06
cozmouz
Рет қаралды 409 М.
How to Make the NPC's Head Look At the Player in Unreal Engine 5
4:54
AI Sight Detection And Chase With Music - Unreal Engine 4 Tutorial
10:51