Download

Writable reference to self?

Happy holidays everyone!

I’m hoping someone can help work out how to get a writable reference to self in blueprints. What I have a tendency to do is make a function (call it F) in BP_A that takes a reference to a BP_B object. Then I have an instance of BP_B with a variable of type BP_A on it, and finally, I try to call F on the BP_A inside of BP_B, passing in self (i.e. BP_B). However, the compiler errors with:

“Cannot pass a read-only variable to a reference parameter”

from which I guess the self reference I am using is read-only. Does anyone know how I can get a writable reference to self, or maybe this is a bug? So far, I can get around this by having a public variable on BP_A of type BP_B, and setting that variable to “self” before calling F, which is quite manky, but works (I believe it’s setting a reference and not making a copy - so far everything is working as intended!)

You want to cast to that BP, and then under the left hand pin “Object” pull your variable reference.

That’s a really nice suggestion, and works fantastically! Cheers!