top of page
Search
  • Writer's pictureKim Ordén

Issues when adding Actor Components to Character in c++

As i was using quite a lot of time in troubleshooting this and it's probably an issue that might come up to others as well, i thought I'd make a blogpost about it.


So i was building my Character in c++ and adding components to it in c++ in the constructor like this after creating my blueprint derivative from my c++ class:




It was all fine and dandy until i needed to add references to these components that i would like to assign in the details panel and was shown a blank details panel when highlighting the component in the editor.


After some heavy googling and troubleshooting to see if my UPROPERTY() macros were set properly i found out that this seems to be a bug in the editor that has been there for some time as referred in this forum post:



So one workaround that actually worked was to reparent the blueprint back to its base level which is Actor and then back to my derived class which is Entity Character, which you can do like this:





This would indeed work, but it also corrupted my blueprint quite drastically and i had to redo o a lot of stuff, references exploded etc.


Also any blueprints referring to these components (like Animation Blueprint for this character and UI blueprints) would get broken in the process, so this wasn't really a solution.


There were some other known workarounds where you would rename component variables -> compile and it could fix the issue which i never tried.


In the end what i ended up doing was just to make sure my actor components are blueprint spawnable components with these UCLASS parameters:



Add the components in blueprint and the details panel seems to be there, which solves the major issue at hand here, but not all.


The whole reason i ran into this issue was that i needed to refer to some SkeletalMeshComponents in my EquipmentComponent to update those meshes when i change the equipment on the character.


As I'm coming from unity i would have assumed that making pointers to said components in c++ with the right UPROPERTY() macro would make it so that i could assign them in the editor like in unity, when you use the [SerializeField] or public keyword for variables in c# for a component, but it only gave me this:



So i can't assign any references to the mesh components nested under my character here like in unity.


I read about FComponentReference which kinda would maybe do the thing, but required some casting to the right types etc. So after some googling i came to the conclusion that just setting these references in the blueprint construction graph would do the trick:





Will post some updates and workaround if i run into further problems as we finish the equipment functionality for the game, but for now there doesn't seem to be an easy way to set component references in the editor like in unity which is a bit of a bummer, but taking into consideration the other benefits of shifting to unreal, this seems like a small price to have to pay.



156 views0 comments

Recent Posts

See All
bottom of page