Why create Interface ?

Hi,

I was wondering why I might need Interface and other blueprint classes implement the function in the Interface ? Can I create one global function and call it from blueprint classes that need this function ?

If it is something that you can do in a global function, go right ahead, absolutely don’t add indirection where you don’t need it :slight_smile:

Where they shine is when used to abstract things, be they actual things or actions, e.g. is some actor the player just clicked on ā€˜interactable’? or ā€˜hitable’? If so you can cast to the interface and send a message to whatever it is saying ā€œI’m interacting with you nowā€ without having to know anything about what it actually is (other than it implements the interactable interface), which is good for numerous reasons.

1 Like