Collecting Items Tutorial - Unreal Engine 5.2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there I'm your host lasoe and in today's video I will show you how to collect some items and have them be displayed on your screen so if we go over to the first sphere over here and if I press f it will say one out of three collected and after three seconds it's going to disappear so we can do that with the second sphere and then of course with our third one so normally after collecting all the items you'd have something like a game finish or Quest completed and you can even open doors with this and things like that so with that said let's begin open up your project and let's go to the content shower now over here I'll go to input actions and let's right click and create a new in production so we can pick up our items and I'll simply call this pickup so let's save this and then in our IMC let's create a new mapping and just call our action so that's going to be pickup and then select whatever key you want I'll have it on F and once you're happy save and exit next let's go to our player and let's go to the game mode of our player so this is going to be game mode Brady for me and from event big and play we will keep track of all of our actors or items rather so let's get all actors of class and here we would have our item and out of actors let's do a length which will return all of our actors and from here do promote to variable call this something like remaining or whatever suits you and out of here let's do promote the variable once more I'm going to call this total then let's connect all of these guys and from here let's do a print string but it's not necessary this is only for testing and I want to see that this is printing the total so to check that let's quickly create a new folder and this will simply be used to keep my widget on my item so blueprint class for the item it will be an actor BP underscore item I think is very descriptive and inside of here I don't have any static meshes so I'm just going to use a sphere now I'll have to call it item and then for the scale 0.3 should do very well I think and yeah let's put that back into here so just search for whatever you called your item and now for magic to see if this works if we put this guy here and let's say we have two if we begin the game we should get to print it and yes this works so The Next Step would be to close the game mode we don't want it anymore and I want to create a widget so let's call this WB for widget blueprint and I'll call it collected and inside of here in the canvas panel or in the designer I want to get a canvas panel and then let's get a text so for the text I missed to put it there for the text let's size the content and the text itself can say x out of Y or whatever you like and these just stand for the numbers so that's fine and Middle top should be good or the size 56 so you can see it and can we Center align it yes we can so then here in the text create a binding and you would cast to your game mode order to blueprint where you have the variables made so that's game mode ready for me and for this it's going to be get game mode like so then let's get our remaining so get remaining and get total like so and of total we want to subtract one remaining and then we would do a text to integer and let's copy this guy paste it and also do it here out of this you would do format text break this chain and in the Box let's type curly brackets X Capital x1o curly brackets to a divide to curly brackets do a y and of curly brackets to a space and say collected and yeah so this will go into X this will go into Y and the result will go to The Returned value that's looking good and one more thing in the event graph delete reconstruct delete the event tick and let's get a delay of three seconds because that's how long I want this widget to appear on the screen once I've picked up an item so uncompleted we will do remove from parents and with that said um I believe that's all good so compile save and exit then inside of our item select self do add and we want to add a collision and since I'm using a sphere a few Collision I think will be sensible so over here let's do what will I call this Collision yes correct and for the sphere radius um let's give it something like 60 so we have some space to pick up our actor and in the event graph let's right click on collision add event add on component begin overlap add on component and overlap so from this guy we will cast to our guy which is going to be Brady or whatever your character is and copy that paste it back and then let's do enable input and here let's do disable this there we go so um then for the player control just get player controller not coin controller and then only then let's delete these three guys and let's get our introduction that we created at the very beginning so from started let's cast again to our game mode or wherever you have your variables object get game mode and we will be decrementing our remaining by one so get remaining and to minus minus then from us game mode pretty once more set remaining and plug this there this here and this here so we are going to decrement by one and then we're going to set it and over here let's do create widget and let's select our widget which we called collected add to viewport and then finally let's get rid of our actor so let's do destroy actor and if I hadn't make any mistakes if I didn't make any mistakes this should work let's compile and see how we did so if I hit play I guess two if I pick this up I get one out of two collected and it'll disappear after three seconds and then we get two out of two collected so now let's say you want to finish a Quest open a door or whatever it may be so to do that you do you would have your input action or whatever your custom event you would cast to Game Mode like we did here then you would get remaining and if this was equal equal or simply equals if this was equal to zero you'd get a branch and if this is true you would have your Open Door your game finished and yeah essentially that so that will be I think it um thank you so much for watching guys if you liked the video leave a like if you didn't leave this like and as always happy developing
Info
Channel: Lisowi
Views: 4,567
Rating: undefined out of 5
Keywords: Unreal Engine Collecting, Unreal Engine Collect, Unreal Engine Number Collected, Unreal Engine Item, UE5 Item, UE5 Collect, UE5 Collect Item
Id: GMDwtFkChWY
Channel Id: undefined
Length: 8min 17sec (497 seconds)
Published: Wed Jul 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.