Soft reference in interfaces creates hard reference dependecy

I have a BPI_Interact interface

This is what it looks like in the reference viewer with no references and therefore no dependencies

When I add a SOFT reference, the reference viewer now looks like this

Why???

PS: posting links to images as well as images because sometimes images disappear

1 Like

Try just using type ‘actor’ :slight_smile: ( then you can just use a hard ref )

This is because interfaces decouple things without the need for soft refs.

Ok that works but it confuses me haha

So like you said, I’ve changed the BP_Character interface reference to Actor (not a soft reference in the interface)

Then over in my interactive prop blueprint (in this case a ladder), I implement the interact event, I can take the Actor reference, cast it as a Character and it’s still decoupled/not dependent/doesn’t show up in the reference viewer - this is good and expected based on your reply


No actor or character shown in the reference viewer

BUT if I do the same thing and instead cast to BP_Character rather than Character, it IS coupled/dependent/shows up in the reference viewer


BP_Character now shown in the reference viewer

Are you able to explain to me why this is the case?

1 Like

The whole point of interfaces is, no more casting :slight_smile:

When you cast, you will get dependencies. You have to talk to actors without casting.

Your ladder can’t access the character moment component. If it does, it ‘knows’ it’s a character and everything is lost.

You have 3 main options

  1. The ladder just moves the player only by knowing it’s an actor

  2. The ladder also uses an interface to get tell the player to do certain things

  3. The player knows how to climb ladders only by knowing they are actors

Hmm that turns this into more of a head scratcher than i anticipated. Thanks for your help!

1 Like

Yes, sorry, that’s the problem :slight_smile:

If you have a tight coupling ( as it’s called ) between the player and the ladder, it means that the ladder concept ( including all textures, code etc ) is loaded all the time your player is loaded.

You can still have a tight coupling if you have a special player you only load for traversing ladders. That’s a possibility. Many methods…

Yes the coupling is exactly what I was hoping to avoid by using interfaces - but I was surprised to see that adding references as inputs on interface functions still leads to coupling anyway regardless of whether the reference is hard or soft🙄

1 Like

You basically can’t mention the type of an object in your blueprint. The moment you mention the type, you create a bond. Casting, and even just having a variable count as mentioning the type

You passed an actor reference, all good, but then you casted it, doh, game over :slight_smile:

So really the only stuff you can pass through an interface (if you want to avoid coupling) is these?

image

Yup, just generic types.

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