Just to add when to use casting: Casting is for working with classes and inheritance. So if a child class has a function you want to call, you have to cast to that child class, before being able to call that function.
@@SellusionStar Blueprint Interface, Event Dispatchers for example. With Casting is quick and easy, you've never thought WHY is that easy this type of Blueprint code? It's easy and quick, for the price of your game's performance. And that's ONE Casting, imagine having hundreds of them ... no no no...
@@chankulovski interesting idea. Also I like your tagging approach. But at the same time using interfaces or dispatchers for managing inheriting classes and using their specific functions feels really cumbersome. It's interesting though. By any chance, do you have a video about the measured performance impact of casting vs. interface/dispatchers?
@SellusionStar Thank you :) The thing is, to use Interface and Dispatchers is a bit more work, slightly more advanced, but the game will run better and chances to crash during gameplay are minimum, whereas when using Casting, chances are high your game to crash. People ignore this on purpose, because using Interface and Duspatchers requires more work (hence optimization). Watch this video and you will see how Casting is increasing the load of the game. As a side note, when I was shipping games with Casting, 4/10 times they crashed. Here's the Casting video: ua-cam.com/video/iVhEL-sWaC8/v-deo.htmlsi=WaXsbZ4v1XBvSJqx
But, usually you need to do some action on destroyed object like make it fire, make it fall, make it play some animation, etc. It is usually not enough just remove it.
@@chankulovski Yes, but then you need to solve that inside of character blueprint. Much more flexible is propagate the destruction even to the target object and lest itself handle the destruction in the proper way.
I heard if the casting is directed to something that will always loaded in the game such as your character, its fine to just keep casting that particular thing. But if its temporary things like normal enemies, once you cast it will still stay in the system and eat up the memory.
@@tuwumuch I explain in great detail why Casting is bad and you should never use it, check that Tutorial on my Channel. Casting is made for prototyping and quick test an idea. Only lazy people are using Casting because they don't want to optimize their code and spend few more extra minutes to do so.
@@chankulovski thanks for the reply but theoretically, if something will always be loaded in isnt it just simple to just cast? Currently I always cast if its directed towards the character or the gamestate/etc, but interface or tags for everything else.
@tuwumuch Those theories are invented by people who wants to use Casting, due to lazyness. To prove this, simply hover over the Casting node and read what it says.
In two months it will be a year since I started working with Unreal Engine, and your video of alternatives for casting is helping me a lot, thank you very much.
The exact same thing happened to me when I first started, after 1 year of using Casting, I've learned alternatives for Casting and I want to teach everyone to not make the same mistake like we did. I'm glad my Tutorials helps you. More to come !
@@chankulovski Thank you men i dont know about Casting issue, i remove unnesserary Castings from my Main Characters , because they have all the Hitboxes and Hurtboxes , i use for the box on the Overlap Component (Get Display Name is equal to a branch) do you think it is expensive? , thank you.
@@kotarosdevgame Get Display Name is just displaying the Actor's name as a TEXT, which is not expensive at all. You are welcome though, most of the developers don't know these things or don't want to accept it. So make sure you remove all Castings in your game ( it will cost you a lot when you package your game with Castings ). More Tutorials are coming !
@@kotarosdevgame Nooooo, that's even worse :( When you start the game immediately you are loading everything from the Character. It's like, you weigh 75kg, but when you start your day next morning to get out of bed, you are suddenly 500kg weight :( Once you get used to the Interfaces and other better nodes, you will say WHY I HAVEN'T DONE THIS BEFORE??? Trust me ... been there done that
@@DailyPaily The Timer was there just to demonstrate how "IsValid" node works. There's another approach for this, but I have to make a whole new Tutorial because it's not that simple :) Thanks for your input, that was a nice catch!
Thanks for this Tutorials. I Have been trying not to use Cast To Node, but in some cases when I need, for example, take the player controller from my CharacterBp, using a Bp_VariableStorage placed in the level as a unique ref "get a copy= 0" and trying to get from it the variable Ref_PlayerController set inside is not working... maybe I'm doing something wrong but the Bp_interface works well to set an specific variable created before. Should I set this In Construct Scrip as a solution??? Thanks again!
Hmm that's strange. You can try with the Construction Script yes, but I think you will get the same outcome. Construction Script will let you run the code BEFORE you press the "Play Button". You can still try and see how it goes.
@@chankulovski for example, when I use a begin collision overlap event and use “cast to” to get for example the mesh and set an animation for it, it’s easy, but trying to do this with a ref when I draw the pin doesn’t show the character mesh… I think I’m doing something wrong definitely
@@jhonyfernandez2703 Yeah, in this case you cannot just drag a pin and extract that information. It needs extra work, and the explanation won't fit into one comment :) I will try and make a Tutorial in the future regarding this.
Actor can perform with interfaces you just have set up you want interface to do you can set and get run event add remove pretty much anything with interface
I need some properties of my character class on the actor class. How can I access those values without casting? Do you have any idea? I used Interface with character reference, but it behaved same as casting, because it is hard reference as well
Yes, if you add your Character as a Reference, it's the same as Casting because you are loading your Character into the Blueprint Interface. If you want to get some information from your Character, please watch this Tutorial and see if it's what you're looking for. I'm explaining everything in depth here: ua-cam.com/video/DmpRbWwJCzY/v-deo.html&ab_channel=Chankulovski Let me know if this will help you.
He urges you to do something, and can't even explain why. just keep in mind to always first make sure you can't use overlap or trace line in a given context.In most cases, you should be able to access with one of these two approaches
I've never used Unreal but I like the presentation a lot.
Thank you for your kind words, I'm really doing my best :)
Just to add when to use casting:
Casting is for working with classes and inheritance. So if a child class has a function you want to call, you have to cast to that child class, before being able to call that function.
Nope. Casting is for lazy people who are trying to find a reason to keep using it. Casting ruins the game performance, it's as simple as that.
@chankulovski but how would you do that task then?
@@SellusionStar Blueprint Interface, Event Dispatchers for example. With Casting is quick and easy, you've never thought WHY is that easy this type of Blueprint code? It's easy and quick, for the price of your game's performance. And that's ONE Casting, imagine having hundreds of them ... no no no...
@@chankulovski interesting idea. Also I like your tagging approach. But at the same time using interfaces or dispatchers for managing inheriting classes and using their specific functions feels really cumbersome. It's interesting though.
By any chance, do you have a video about the measured performance impact of casting vs. interface/dispatchers?
@SellusionStar Thank you :) The thing is, to use Interface and Dispatchers is a bit more work, slightly more advanced, but the game will run better and chances to crash during gameplay are minimum, whereas when using Casting, chances are high your game to crash. People ignore this on purpose, because using Interface and Duspatchers requires more work (hence optimization).
Watch this video and you will see how Casting is increasing the load of the game. As a side note, when I was shipping games with Casting, 4/10 times they crashed.
Here's the Casting video:
ua-cam.com/video/iVhEL-sWaC8/v-deo.htmlsi=WaXsbZ4v1XBvSJqx
But, usually you need to do some action on destroyed object like make it fire, make it fall, make it play some animation, etc. It is usually not enough just remove it.
That can be added easily, just make sure to put the Blueprints BEFORE the destroy Component / Actor.
@@chankulovski Yes, but then you need to solve that inside of character blueprint. Much more flexible is propagate the destruction even to the target object and lest itself handle the destruction in the proper way.
Thanks for another great tut!
You are welcome ! More to come ✌️
Fantastic video. Thank you.
@@MichaelBullo Thank you very much, I really appreciate it.
@@chankulovski Best of luck with the channel
@@MichaelBullo Thank you! Doing my best to push as much knowledge as possible, especially for beginners.
@@chankulovski Excellent. You are getting close to 1000 subscribers.
I heard if the casting is directed to something that will always loaded in the game such as your character, its fine to just keep casting that particular thing.
But if its temporary things like normal enemies, once you cast it will still stay in the system and eat up the memory.
@@tuwumuch I explain in great detail why Casting is bad and you should never use it, check that Tutorial on my Channel. Casting is made for prototyping and quick test an idea. Only lazy people are using Casting because they don't want to optimize their code and spend few more extra minutes to do so.
@@chankulovski thanks for the reply but theoretically, if something will always be loaded in isnt it just simple to just cast? Currently I always cast if its directed towards the character or the gamestate/etc, but interface or tags for everything else.
@tuwumuch Those theories are invented by people who wants to use Casting, due to lazyness. To prove this, simply hover over the Casting node and read what it says.
@@chankulovski yes i saw your video it'll always be loaded. Character is always loaded though no?
@tuwumuch Yes
Excelente vídeo, from Brasil.
Obrigado Brasil! ❤
U got a subscriber Sir, nice viedos, keep it up
Thank you very much, I appreciate it! You will learn a lot from these Tutorials :)
In two months it will be a year since I started working with Unreal Engine, and your video of alternatives for casting is helping me a lot, thank you very much.
The exact same thing happened to me when I first started, after 1 year of using Casting, I've learned alternatives for Casting and I want to teach everyone to not make the same mistake like we did. I'm glad my Tutorials helps you. More to come !
@@chankulovski Thank you men i dont know about Casting issue, i remove unnesserary Castings from my Main Characters , because they have all the Hitboxes and Hurtboxes , i use for the box on the Overlap Component (Get Display Name is equal to a branch) do you think it is expensive? , thank you.
@@kotarosdevgame Get Display Name is just displaying the Actor's name as a TEXT, which is not expensive at all. You are welcome though, most of the developers don't know these things or don't want to accept it. So make sure you remove all Castings in your game ( it will cost you a lot when you package your game with Castings ). More Tutorials are coming !
@@chankulovski I will try it i used so much 🤣 but just at the start of the begin play ( Cast to Character to promote to a variable to get a reference.
@@kotarosdevgame Nooooo, that's even worse :( When you start the game immediately you are loading everything from the Character. It's like, you weigh 75kg, but when you start your day next morning to get out of bed, you are suddenly 500kg weight :( Once you get used to the Interfaces and other better nodes, you will say WHY I HAVEN'T DONE THIS BEFORE??? Trust me ... been there done that
How about using HasInterface? Does it cost more than HasTag?
I believe it cost more, because you have to create the Blueprint Interface. This is just a Text tag.
My 2 cents: Join Branch with 'clear and Invalidate' and skip one step.
Its necessary 'Clear' after one single loop ?
@@DailyPaily My apologies, but I didn't understand this?
@@chankulovski 12:53 Branch ---> Clear and Invalidate, you will save the 'is valid' node.
@@DailyPaily The Timer was there just to demonstrate how "IsValid" node works. There's another approach for this, but I have to make a whole new Tutorial because it's not that simple :) Thanks for your input, that was a nice catch!
@@chankulovski Cool !
Thanks for this Tutorials. I Have been trying not to use Cast To Node, but in some cases when I need, for example, take the player controller from my CharacterBp, using a Bp_VariableStorage placed in the level as a unique ref "get a copy= 0" and trying to get from it the variable Ref_PlayerController set inside is not working... maybe I'm doing something wrong but the Bp_interface works well to set an specific variable created before. Should I set this In Construct Scrip as a solution??? Thanks again!
Hmm that's strange. You can try with the Construction Script yes, but I think you will get the same outcome. Construction Script will let you run the code BEFORE you press the "Play Button". You can still try and see how it goes.
@@chankulovski for example, when I use a begin collision overlap event and use “cast to” to get for example the mesh and set an animation for it, it’s easy, but trying to do this with a ref when I draw the pin doesn’t show the character mesh… I think I’m doing something wrong definitely
@@jhonyfernandez2703 Yeah, in this case you cannot just drag a pin and extract that information. It needs extra work, and the explanation won't fit into one comment :) I will try and make a Tutorial in the future regarding this.
@@chankulovski thank you! We will waiting for it!
it is usefull for destroying actor but actors contain code you cant perform without casting
@@newwonderer You can perform without Casting, there is a way around it.
Actor can perform with interfaces you just have set up you want interface to do you can set and get run event add remove pretty much anything with interface
@@MikeReed-r8r That's right!
I need some properties of my character class on the actor class. How can I access those values without casting? Do you have any idea? I used Interface with character reference, but it behaved same as casting, because it is hard reference as well
Yes, if you add your Character as a Reference, it's the same as Casting because you are loading your Character into the Blueprint Interface. If you want to get some information from your Character, please watch this Tutorial and see if it's what you're looking for. I'm explaining everything in depth here:
ua-cam.com/video/DmpRbWwJCzY/v-deo.html&ab_channel=Chankulovski
Let me know if this will help you.
@@chankulovski I will watch and say my experiences to you
He urges you to do something, and can't even explain why. just keep in mind to always first make sure you can't use overlap or trace line in a given context.In most cases, you should be able to access with one of these two approaches
Бро реально притворяется енглишменом
My Channel is english speaking only, please write your comments in english, thank you :)