Unreal Engine Copies VS References EXPLAINED

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

КОМЕНТАРІ • 8

  • @juggernautx1779
    @juggernautx1779 8 місяців тому +2

    Finally someone covered this properly!

  • @Wrexthor
    @Wrexthor 8 місяців тому +1

    Love videos like this that cover basic but often overlooked things, please keep doing it!

  • @GrumpyGillsFishing
    @GrumpyGillsFishing 3 дні тому

    Excellent! I think this might actually solve my issue

  • @carlosrivadulla8903
    @carlosrivadulla8903 8 місяців тому

    If checking "pass by ref" modifies the original variable without setting it back or returning it from the function. What the node "set float(double-precission)(by ref)" is for?.

    • @thegamedevcave
      @thegamedevcave  8 місяців тому +1

      It sets the value? You still need to set values the + node by itself doesnt execute anything.
      As shown in the video, you need to pass in a ref and then set it. If you try to set with that node without pass by ref, it sets the value of the local copy, not the original value that you put in

  • @philipberick2874
    @philipberick2874 2 місяці тому

    I am really sorry if this is a dumb question but I am failing to understand the advantage here.. you are still "getting" the variable at a point and "setting" it at another point, in both examples (the usual way and the "pass by reference" way.) So what is the real point? Is it more efficient for processing maybe? Or, is it something that is not really an advantage for such a simple example but would be much more efficient and powerful for some complex function?

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +1

      with a pass by ref you can set the new value *inside* of the function, if you dont use pass by ref, you need the function to return the new value and then manually set it *outside* the function every time you use it.
      Let's say you have a shop with a function for "Buy Item" that takes in a money variable from the player. a function called that, you would assume takes care of subtracting the money by itself, it would be a little weird if it just calculates the new value of money and then makes you set it afterwards. that can become really tedious if it's a function that you use a lot.
      Like many things in programming, it's not like this little bit of info allows for things that were not possible without it, you very much can just add a setting node after running the function every time if that makes more sense to you, but it has more chance of a mistake slipping in somewhere and it will likely make a bit less sense to other people if they have to look at or work with your code.