How to init Actor for in-editor use?

Upon loading my project in the editor I would like to see the actor’s mesh reflect various blueprint variable values. The actor’s C++ class has PostEditChangeProperty overridden and it properly updates the mesh when said BP variables change, however, upon loading the level the mesh is at the default state because no “change” has happened.

I’ve taken a look at the following post:

And I’ve tried PostLoad and PostRegisterAllComponents without success. In PostLoad the PoseableMesh isn’t ready as I get problems accessing LocalAtoms array, and in PostRegisterAllComponents the change doesn’t seem to take either in addition to a chicken-and-egg problem because PostRegisterAllComponents is always triggered after PostEditChangeProperty. How can I seed that first editor update to Actor?

Hi Dekrat,

Can you upload the code related to this actor that is having these issues? Also, are you saying that if you change a variable in the details tab of the editor or the blueprint editor, these values are reset to default when you press Play?

link text

I’ve attached the actor code. It uses a separate module called VmgModule that provides dataglove which in turn will transform mesh accordingly. That part of the code isn’t implemented yet, however, all the prep work ready for it is there.

This class is used as a parent class for a blueprint. The blueprint is then instanced into the level and the purpose of the BP readwrite FRotator variables is for me to empirically figure out the starting position of the mesh in the editor. When I load up the project the mesh appears in the editor in its original default transformation state. But the moment I make a change to one of the BP variables, even inconsequential like change a rotator field from 0.0 to 0.1, the mesh updates to the state that reflects all the BP vars.

The runtime behavior of the actor is fine. I’m really only talking about in-editor behavior. The goal is to update the mesh when the actor first loads into the editor.

Are you referring to changing the values titled “Mesh Relative Location”, “Left Shoulder Rotation” and so on? If so, when I change these values, it updates in the Viewport for the blueprint editor, but never updates in the game’s viewport unless a new instance is placed after the change has been committed. Is this the issue you’re experiencing?

Yes, I am referring to “Mesh Relative Location”, “Left Shoulder Rotation” etc. The mesh in the editor viewport does indeed change when I change those values. The problem is that when the project loads up that mesh doesn’t reflect those values until I make any change, even an inconsequential one, so that the mesh update code runs. What I am trying to figure out is how to get that first update mesh to run upon the project first loading without have to manually trigger the update.

What is the last override-able function that is called on an in-editor actor instance such that basically everything has been initialized? PostLoad certainly isn’t it because accessing the LocalAtoms array in the PoseableMesh crashes the program at that time. Something other than PostRegisterAllComponents perhaps?

OK I figured out something workable to do what I want. I now do all of my initializations in ::PostLoad, however, I need a call to AllocateTransformData() first so that LocalAtoms array in PoseableMesh becomes available. This allows the mesh to load up in the editor with the right starting pose – my original goal. Then the UpdateBones function (called by Tick) takes care of mesh transformations during runtime.

It helpful understanding which functions (PostLoad, PostInitComponents, … ) run in which particular class instances (VmgChar_C_1, VmgChar_C_0) during editor vs runtime startup, which I figured out by tagging said functions with logs.

Regardless, thank you for answering and trying to help. :slight_smile:

1 Like

Glad to hear that you found a solution in my absence. Have a good day!