Property Access System - Can I access a property requiring a cast?

So, I think I actually finally found the answer to this. I’m still doing some testing, but it looks like the answer is actually in the Lyra sample as well, it’s just hidden.
What you can do is create your own Thread Safe function in the Anim Blueprint, and in that function, you can perform the cast. Then return the casted result. There is a sample in the Lyra project (ABP_ItemAnimLayerBase->GetMainAnimBPThreadSafe()) that does this. One of the crucial bits is that in order for this to work, the return value of the function must be named ReturnValue, or it won’t work. SO there’s some kind of interesting code behind the scenes in Property Access, but it seems to work.

So in my case, I create a function called GetLyraCharacterThreadSafe, as shown below.

Then in my ThreadSafeUpdateAnimation function, I can use Property Access, using my newly created function, to get my Ragdoll variable, as shown below:

And it seems to actually work. Be sure to pay attention to the Pure and Thread Safe attributes when creating your functions, and again, the return value MUST be named ReturnValue, but I think this actually opens up a lot more flexibility for using the PropertyAccess functionality.

Note: I’m not smart enough to figure out if this is causing some sort of additional overhead or slowdown, and I also suspect that there’s at least the potential for errors (remember, any cast CAN fail, and I assume that will break something, but in my cast I know my cast should be a safe one). I’m also not sure this is the “official” way to do it…but there IS an example of exactly this sort of logic in the Lyra starter kit.

Would love to hear from Epic or someone with more experience if this is really the correct way. Maybe this is just something obvious to everyone else, but it took me a while to figure it out.

8 Likes