“it seems UE4 cannot handle circular reference with Macro Library involved correctly.” Is it just a guess or u have faced something similar? Can u please explain ur point more precisely? We have already fixed that problem, but still it is very interesting question for which we have no answer. Moreover, ur answer might come to someone as a treatment.
Yes @Erumaru, we’ve encountered a similar issue in our project, however I’m not sure if it is the same problem we’ve both faced. The issue is quite complex, I’ll try to explain it with a minimal case.
Let’s say you have the following blueprint classes:
- abstract class Weapon inherits Actor
- class Sword inherits Weapon
- class MyCharacter inherits Character
In MyCharacter, there is a variable of type Weapon; while in Weapon, a macro blueprint library, MBL, is used, in which there is a macro with MyCharacter involved (e.g. a GetHitCharacter macro which accepts a HitResult structure and simply casts the hit actor to a MyCharacter instance). A circular reference is therefore formed.
If you assign Sword to the Weapon variable in a Character, the issue could raise when compiling blueprints. UE4 blueprint compilation is consisted of 3 stages: skeleton, full and bytecode(ignore this one because it has nothing to do with our problem). Because of the existing of the skeleton stage, circular references could be handled correctly in most cases, however this is not true if macro library acts as a part of the reference chain. It requires the classes used within it to be fully compiled. Let’s take a look at the compilation process in our example:
- Compile Sword in skeleton stage
- Because Sword is a subclass of Weapon, compile Weapon in skeleton stage first (stack push)
- Weapon uses MBL, compile MBL first (stack push)
- MBL uses MyCharacter, compile it FULLY (stack push)
- MyCharacter uses Weapon, compile it FULLY
- When fully compiling Weapon, a skeleton compilation is already taking in place (see step 2), so it’s SKIPPED. However Weapon is still fully compiled
- when the stack is popped to step 2, we are back to the skeleton compilation of Weapon. However Weapon is ALREADY FULLY COMPILED, so it seems there is no need to do it again. Therefore, the skeleton class of Weapon is left EMPTY, and will be FALLBACK to Actor.
This is the cause of our problem, maybe yours as well. The explanation is base on my memory so it might not be very accurate, but I hope it can help you to grab the idea. It should be addressed as a bug by the Epic guys, but I don’t have time to get on this problem and create a reproduce-able environment recently
this should be the answer
Didn’t help me, why it should?
This is very close to what we have experienced. Thank you for explanation, I hope it will be useful for someone.