Diference between object type and interface type

In unreal, what is the difference between storing an object of a type, and storing an interface that an object implements?

e.g:

  1. Storing an interface type implemented by an object

  2. Storing the object itself

I’ll try to be as simple as possible when explaining. Imagine you have two boxes: one is a toy box (this is like storing an object itself), and the other is a magic box (this is like storing an interface).

Toy Box (Storing the object itself):
In the toy box, you can see and play with all the toys directly. Each toy is something specific, like a race car or a doll. You know exactly what each toy can do because you can see and touch it. But, if you want to play with something different, you need to go get a new toy that might not fit in this particular toy box.

Magic Box (Storing an interface the object implements):
In the magic box, you don’t see the toys directly. Instead, you know that any toy you pull out will do something fun, like make music or light up, but you’re not sure exactly what toy it will be. The magic box can hold any toy, as long as it can do that fun thing you like. This means you can swap the toys in and out, and it doesn’t matter what the toy is, as long as it does the special thing you want.

So, with the toy box, you know exactly what toys you’re playing with, but it’s not as easy to switch them out. With the magic box, you can easily switch toys as long as they do what you expect, but you might not know exactly what the toy looks like until you pull it out. Also it’s better memory-wise to not store an object directly, if that object has other relatives, those will also have to be loaded.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.