Download

Is casting = association?

Hi, just trying to draw some parallels
Is casting to some class in blueprints is the same like like association? Aggregation?
Or is association just any variable that is a reference of some other class? Like, Source Preset Object Reference? What are the casts then?

Casts are casts. A utilility to find the dynamic type of a referenced object.

Maybe that will help someone, but its a bit too much academic-textbook for me… Below is my 2c attempt at some kind of analogy:

Think of all your Blueprint classes as locked Rooms. Which is kind of apt anyway in Objected-Oriented-Programming / design etc.
A cast node is like a door lock. If you pick the right cast-node and supply the right object ‘Key’ you can unlock the door/get access.

So think of Casts as an attempt to Access something or gain entry, and not so much anything to do with association / aggregation.

Under the hood, casting is a type of test. Is this object of this type, yes / no - success / fail. If yes, give me access. If not don’t etc etc.
Some BP Rooms have multiple floors, or child / parent relationships, and they have their own particular door / require their own key.

Casting has a long history

Say you’ve got an integer but need to display it (Print String) you cast it from Int-To-String, which gives you ‘access to it’ as a string…
The reason you need to do this at all is, at compiler / assembler-level, handling a number as a number vs a string is vastly different.
This got carried over into Object-Oriented-Programming and that’s why Casting also exists in BP, but at the expense of clarity imho.