How to use Tags instead of Casting node | Unreal Engine 5 Tutorial

Поділитися
Вставка
  • Опубліковано 23 лис 2024

КОМЕНТАРІ • 62

  • @blossomcherrypink
    @blossomcherrypink 6 місяців тому +2

    I've never used Unreal but I like the presentation a lot.

    • @chankulovski
      @chankulovski  6 місяців тому

      Thank you for your kind words, I'm really doing my best :)

  • @SellusionStar
    @SellusionStar 6 днів тому

    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.

    • @chankulovski
      @chankulovski  6 днів тому +1

      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.

    • @SellusionStar
      @SellusionStar 6 днів тому

      @chankulovski but how would you do that task then?

    • @chankulovski
      @chankulovski  5 днів тому +1

      @@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...

    • @SellusionStar
      @SellusionStar 5 днів тому

      @@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?

    • @chankulovski
      @chankulovski  5 днів тому +1

      @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

  • @ATomCzech
    @ATomCzech 6 місяців тому +1

    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
      @chankulovski  6 місяців тому

      That can be added easily, just make sure to put the Blueprints BEFORE the destroy Component / Actor.

    • @ATomCzech
      @ATomCzech 6 місяців тому +1

      @@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.

  • @norvsta
    @norvsta 6 місяців тому

    Thanks for another great tut!

    • @chankulovski
      @chankulovski  6 місяців тому +1

      You are welcome ! More to come ✌️

  • @MichaelBullo
    @MichaelBullo 23 дні тому

    Fantastic video. Thank you.

    • @chankulovski
      @chankulovski  23 дні тому

      @@MichaelBullo Thank you very much, I really appreciate it.

    • @MichaelBullo
      @MichaelBullo 23 дні тому

      @@chankulovski Best of luck with the channel

    • @chankulovski
      @chankulovski  23 дні тому

      @@MichaelBullo Thank you! Doing my best to push as much knowledge as possible, especially for beginners.

    • @MichaelBullo
      @MichaelBullo 23 дні тому

      @@chankulovski Excellent. You are getting close to 1000 subscribers.

  • @tuwumuch
    @tuwumuch 18 днів тому

    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.

    • @chankulovski
      @chankulovski  18 днів тому

      @@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.

    • @tuwumuch
      @tuwumuch 18 днів тому

      @@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.

    • @chankulovski
      @chankulovski  18 днів тому

      @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.

    • @tuwumuch
      @tuwumuch 18 днів тому

      @@chankulovski yes i saw your video it'll always be loaded. Character is always loaded though no?

    • @chankulovski
      @chankulovski  18 днів тому +1

      @tuwumuch Yes

  • @fabioalmeida6660
    @fabioalmeida6660 13 днів тому

    Excelente vídeo, from Brasil.

  • @ankitsharma-ud7tq
    @ankitsharma-ud7tq 10 днів тому

    U got a subscriber Sir, nice viedos, keep it up

    • @chankulovski
      @chankulovski  10 днів тому

      Thank you very much, I appreciate it! You will learn a lot from these Tutorials :)

  • @Walison_178
    @Walison_178 6 місяців тому +1

    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.

    • @chankulovski
      @chankulovski  6 місяців тому +1

      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 !

    • @kotarosdevgame
      @kotarosdevgame 6 місяців тому

      @@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.

    • @chankulovski
      @chankulovski  6 місяців тому +1

      @@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
      @kotarosdevgame 6 місяців тому

      @@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.

    • @chankulovski
      @chankulovski  6 місяців тому +2

      @@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

  • @RobertBojor
    @RobertBojor 4 дні тому

    How about using HasInterface? Does it cost more than HasTag?

    • @chankulovski
      @chankulovski  4 дні тому

      I believe it cost more, because you have to create the Blueprint Interface. This is just a Text tag.

  • @DailyPaily
    @DailyPaily 17 днів тому

    My 2 cents: Join Branch with 'clear and Invalidate' and skip one step.
    Its necessary 'Clear' after one single loop ?

    • @chankulovski
      @chankulovski  17 днів тому

      @@DailyPaily My apologies, but I didn't understand this?

    • @DailyPaily
      @DailyPaily 17 днів тому

      @@chankulovski 12:53 Branch ---> Clear and Invalidate, you will save the 'is valid' node.

    • @chankulovski
      @chankulovski  17 днів тому

      @@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!

    • @DailyPaily
      @DailyPaily 17 днів тому

      @@chankulovski Cool !

  • @jhonyfernandez2703
    @jhonyfernandez2703 Місяць тому

    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!

    • @chankulovski
      @chankulovski  Місяць тому +1

      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.

    • @jhonyfernandez2703
      @jhonyfernandez2703 Місяць тому

      @@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

    • @chankulovski
      @chankulovski  Місяць тому +1

      @@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.

    • @jhonyfernandez2703
      @jhonyfernandez2703 Місяць тому

      @@chankulovski thank you! We will waiting for it!

  • @newwonderer
    @newwonderer 23 дні тому +1

    it is usefull for destroying actor but actors contain code you cant perform without casting

    • @chankulovski
      @chankulovski  23 дні тому

      @@newwonderer You can perform without Casting, there is a way around it.

    • @MikeReed-r8r
      @MikeReed-r8r 10 днів тому

      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

    • @chankulovski
      @chankulovski  10 днів тому

      @@MikeReed-r8r That's right!

  • @nastenkaoo
    @nastenkaoo Місяць тому

    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

    • @chankulovski
      @chankulovski  Місяць тому

      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.

    • @nastenkaoo
      @nastenkaoo Місяць тому

      @@chankulovski I will watch and say my experiences to you

    • @minezmartw
      @minezmartw Місяць тому

      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

  • @chach430
    @chach430 6 місяців тому

    Бро реально притворяется енглишменом

    • @chankulovski
      @chankulovski  6 місяців тому +1

      My Channel is english speaking only, please write your comments in english, thank you :)