Unreal Engine - Is "Casting" Bad?

  Рет қаралды 12,597

Beardgames

Beardgames

Күн бұрын

Пікірлер: 43
@syrus2128
@syrus2128 2 жыл бұрын
Very interesting! I never knew cast nodes could be such a pain when working on big releases. I used to never use them and instead use "get all actors of class". This was all fun and games until I stumbled upon overlap events lol. Anyways, nice video and very instructive!
@Beardgames
@Beardgames 2 жыл бұрын
Thanks Syrus hope it helped 🙂
@pawprinting
@pawprinting Жыл бұрын
@@Beardgames What about the performance cost of casting directly to a C++ gameinstance? I mean this is something that is essential to programming. In most cases those things have to be used along with onTick as well to constantly update the code.
@earthbornjim9975
@earthbornjim9975 2 жыл бұрын
Thanks heaps for this and the Interface video you made. I didn't realize just how wrong I was doing things by setting references here and there and using casting when I really just needed to use Interfaces. I guess I never really understood hard references and their impact as everything was working and seemed easy enough. I've now gone through my project and modified everything I could to interfaces and when looking at the reference viewer it's been cut down dramatically for most things. Its also made things so much easier to manage as I don't need to remember all the different references i've set and if they're going to cause trouble down the line. Thanks heaps!
@Beardgames
@Beardgames 2 жыл бұрын
Hey it's a slow process improving efficiency, looks like you're well on your way now good job 😎 Anytime brother thanks for watching and supporting the content!!
@crown9413
@crown9413 2 жыл бұрын
I would also add, take advantage of the blueprint hierarchy its better to cast to a base level class like Actor or Pawn. For example say you have ten different types of unit in rts game casting to each one will force the game to load in all the assets related to those units which will hold up a ton of memory, you could instead cast to a parent of those classes in which you have the minimal functions you need for them.
@Beardgames
@Beardgames 2 жыл бұрын
Well said good sir
@shannenmr
@shannenmr 2 жыл бұрын
Some potential alternatives / optimisations: * Have Base C++ classes as Casting to those doesn't create a hard reference * Use a Interface to communicate between Classes that doesnt create a hard reference * Create a Base BP class that contains just the logic and code and then child class with just the Object References which take up memory like Meshes and Sounds etc ... this way you only creating a hard reference to a code only BP * Use Soft Object References in your BP's to then later in your code ASync load items that take up large amounts of memory as its needed, similar outcome to Base class BP's as Casting should only hard reference the code portion of your BP or anything you didn't Soft Reference in the BP
@dadlord689
@dadlord689 2 жыл бұрын
You don't need to cast when you accessing inherited functionality. When you passing an object as it's ancestor - there is no casting goin on. And downcasting is just a flaw in architecture design. But that's why you have interfaces and they are allowing multiple inheritance (you can have as many as you want). But yet it is better to use composition over inheritance (components pattern).
@DoctorMGL
@DoctorMGL Жыл бұрын
in my experience the only blueprint that cause a lot of performance drop when casting it is "Character Blueprint" it has a heaviest connection compare to the rest of blueprints in your game because it have to read trough all the < key binding /animations/ tweaking/ animMontages / physics / vfx /sfx / ik /bones .. ta ta ta ... etc > all in one file so i'd cast other blueprints but avoid as much as you can casing characterBP itself in general Avoid casting heavy blueprints that has a larg heavy codes and use interface whatever you fall into such situation
@sdrawkcab_emanresu
@sdrawkcab_emanresu 2 жыл бұрын
Can you make a tutorial on the best ways to avoid cast nodes? I know you already made one about interfaces, but there are other situations, where that doesn't work, and an overview would be great
@Beardgames
@Beardgames 2 жыл бұрын
Have a read of the article in the description it goes over some other methods to use to avoid them but primarily it's blueprint interfaces my friend 🙂
@tuatec
@tuatec 2 жыл бұрын
I use interfaces a lot. This does not introduce a hard reference. 😉
@fracturedfantasy
@fracturedfantasy 2 жыл бұрын
I like the point you make about the hard references that are already there. A good thing to do would be to check the reference first, and then make your decision. As always thanks my friend. 💪
@Beardgames
@Beardgames 2 жыл бұрын
Anytime brother thanks for the kind and intelligent comments as always🙏👊🏻
@ThatOpinionIsWrong
@ThatOpinionIsWrong 2 жыл бұрын
Wouldn't setting variables as references solve this problem? For example whenever you want to reach PlayerController inside your Character you would have to GetController > Cast to BP_PlayerController everytime, what if instead, on BeginPlay or some other event that you want to set up your character you would cast to PlayerController only ONCE and saved it as a variable inside the Character blueprint? That way everytime you wanted to call PlayerController you would simply use the already made variable? I know this doesn't apply to dynamically created references but it would save performance when dealing with things that are regularly called.
@Beardgames
@Beardgames 2 жыл бұрын
Unfortunately simply having the cast to node will create a hard reference. That being said it's still more efficient creating a reference to it then to keep using the cast to node 🙂
@gamerdweebentertainment1616
@gamerdweebentertainment1616 2 жыл бұрын
and have Tons of components on player character instead :) For me coding gets a bit complicated, for my sanity sake I started to name functions, dispatcher etc by adding a refrence... Kind of jarring when you have multiple Interact functions and such or recently on clicked... On clicked, call on clicked, bind on clicked... etc
@geeksinsuits
@geeksinsuits 2 жыл бұрын
As new to UE5 BP i just learned how to use Cast node to communicate and i was happy about it lol !
@Beardgames
@Beardgames 2 жыл бұрын
Don't change my good friend, learning passing references is a long process of learning which you build gradually! Stick with the cast know but know that there are more efficient methods which you can adopt over time 🙂
@tuatec
@tuatec 2 жыл бұрын
Why do casting nodes increase memory consumption if we use references to store them? I thought a reference is kind of a pointer in C++ and there we only need to store the address.
@Retrocaus
@Retrocaus 2 жыл бұрын
yea in c++ if you cast to a c++ class I heard that is exactly what happens, but when you cast to a BP_ then It loads the entire bp and its casts
@ZzZz-dr7uq
@ZzZz-dr7uq 2 жыл бұрын
great video short and precise
@BlueprintBro
@BlueprintBro Жыл бұрын
Thank you for this
@samiam.402
@samiam.402 2 жыл бұрын
So when I have an actor reference as a character within another actor blueprint, is this also considered a "hard reference"? So when I do that and edit it on instance within my level, is it as harsh on memory as casting is or is the easier? Also, how would you measure how harsh these references are on performance?
@kendarr
@kendarr Жыл бұрын
So, I have a character, and I often cast from my guns to the character, I'm just making a hard reference to my character right? Which for me is good since the character is my player, it will always be loaded. Or by casting to the character from all of my 5 guns, I'm loading all of these 5 guns in memory? EDIT: I'm casting to the character because my guns have all of their code to function in them, so all firing, ammo, everything is in the gun blueprint, the character only fires, reloads and holds the total ammo.
@kendarr
@kendarr Жыл бұрын
@@themeangene It's fairly small, something like 10v10 free for all or something like this, I wanted to get my hands dirty with game dev, and yes I'm aware I should not have choosen an online game at first lol
@chaosordeal294
@chaosordeal294 7 ай бұрын
If you're loading a character, you probably want the model, mats, functions, and animations, anyway. Better to load them up front than during play.
@ashensamurai8072
@ashensamurai8072 2 жыл бұрын
where can i hire devs with your skills for a project?
@nicholaspatton3797
@nicholaspatton3797 2 жыл бұрын
I have a question relating to game development. If someone wanted to create a game where players can tame monsters in order to either fight other monsters, solve puzzles, etc., how would someone set it up?
@PsyCoCinematics
@PsyCoCinematics 2 жыл бұрын
One step at a time. Break all the things you want down into bits, then cut those bits down even smaller if it helps. Like asking how to make a sandwich, you'll need bread, meat, cheese, mayo, etc. But you'll also need a plate to put it on, the bread and other ingredients were in their own containers, a knife to spread the mayo was made from some metal. The drawer the knife came from has different sections and is a shelf. The shelf can open because of wheels. Wheels work because of gravity. Gravity works because the Earth revolves around the Sun etc etc. Worrying about ALL of that at once doesn't help. But doing one tiny bit at a time lets you piece it all together, and fix parts that need touching up along the way ^_^
@madaraainna
@madaraainna 2 жыл бұрын
@@PsyCoCinematics pffft. Wrong
@PsyCoCinematics
@PsyCoCinematics 2 жыл бұрын
@@madaraainna Haha, okay.
@samiam.402
@samiam.402 2 жыл бұрын
Just curious how much unreal experience you have? If it's not a lot, I would write down all those feature you want for your game, and practice by making even smaller projects that have just a single feature done, really well. Then as you are more comfortable with it, you can use all your knowledge to put it all together into one big project like you said.
@KJ-rc3io
@KJ-rc3io Жыл бұрын
Is casting to player character bp bad? Isn't that blueprint always loaded into memory since it controls the player?
@starrunner3220
@starrunner3220 Жыл бұрын
good question
@trenerjakub2605
@trenerjakub2605 2 жыл бұрын
Hi, I have a question. what would be your advice for developers who want to make an fps game? where to start? or where do you start first? thank you for your answer have a nice day and much success.
@crown9413
@crown9413 2 жыл бұрын
Look at as many projects as you can there's a few on the learn tab of the launcher particularly the content examples, there's also a shooter game example there. Make minigames and game jams. Start small one feature at a time. I'm a tech artist that's how I got started.
@ThatOpinionIsWrong
@ThatOpinionIsWrong 2 жыл бұрын
Look for FPS tutorials on youtube. Look for channels "SargKyle", "Awesome Tuts", "vPoly", they made tutorials for UE4 but it's pretty much the same case on UE5. Start simple at first, for your first project I'd recommend making something like original DOOM from 90s. Focus on making the guns work, shooting, picking up health & ammo, enemies, opening doors, keycards, just the absolute basics. DOOM is a smple game and you will teach yourself the basics without worrying about milion trivial things of the modern shooters. Try to make a working game from start to finish, as in, make a functioning main menu, some levels, gameplay loop (going from the start to the end of the level, dying, killing, objecties etc.). Good luck.
@Beardgames
@Beardgames 2 жыл бұрын
Just keep learning my friend! Even if it's not FPS related just learn all the ins and outs about unreal as they all come together regardless of what game you're producing 🙂 good luck Trenor!
@StarvingWolff
@StarvingWolff 2 жыл бұрын
Hey man i have an issue with your tutorial for inventory system. See when we press the same item slot it hides the Use/Drop button just fine but not when pressing a different item slot, so both show and it looks super bad. how can we make it so it hides it regardless of which item slot we press? a tutorial for that would be amazing!
@DuneGames
@DuneGames 2 жыл бұрын
I don't see how interfaces help with memory. You still have to call the interface function on that 'reference' when you use it. And the caller will reside in memory until the reference interfaced function is done processing. Interfaces help with communication by making it available on objects that typically don't have that 'interface'. If the object your calling has a 'AddDamage' function, you wouldn't add an interface to simply call 'AddDamage' on it. You'd call the intended AddDamage. Though if it was a wall, which typically don't take damage, but you wanted it too. Then an interface to handle 'AddDamage' would suit it just fine. And you'd cast the wall actor to the interface, and if it was valid, you'd call the interface > 'AddDamage' on it.
@Will_278
@Will_278 2 жыл бұрын
Hello could you make a tutorial where a character automatically unequips a sword when not in combat please
Casting Explained | Unreal Engine 5 Tutorial
11:14
Tyler Serino
Рет қаралды 40 М.
Unreal Engine - Blueprint Interfaces Tutorial
6:14
Beardgames
Рет қаралды 55 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 188 МЛН
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 156 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,3 МЛН
Unreal Engine - Sound and Music In 6 Minutes
5:56
Beardgames
Рет қаралды 61 М.
Unreal Engine - Casting and Interfaces Explained
21:31
Reids Channel
Рет қаралды 32 М.
Unreal Engine - Get Free Working Animations With Mixamo!
3:47
Beardgames
Рет қаралды 11 М.
Unreal Engine - Channel & Flexible Combat System Update
5:31
Beardgames
Рет қаралды 6 М.
How to... Cast Vs Interfaces
6:07
Ryan Laley
Рет қаралды 25 М.
SOFT Object References in Unreal Engine EXPLAINED
11:58
The Game Dev Cave
Рет қаралды 14 М.
I Struggled With Blueprint Interfaces for Years!! (Unreal Engine 5)
16:48
Glass Hand Studios
Рет қаралды 191 М.
Unreal engine (Multiplayer) AI And Player Mantle System
5:30
How to Cast in Unreal Engine 5
4:04
Nils Gallist
Рет қаралды 63 М.
Unreal Engine 5 - How To Create Cinematics in Sequencer Tutorial
17:35
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 188 МЛН