Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When subclassing ALS Character BP with a class from a third party library, StaticMesh becomes null #42

Closed
HeyZoos opened this issue Aug 15, 2020 · 1 comment
Labels
invalid This doesn't seem right

Comments

@HeyZoos
Copy link

HeyZoos commented Aug 15, 2020

I'm not sure if this applies to all third party libraries, but I'm using the AdvancedJigsawInventory library in particular.

To replicate:

  • Reparent the TPMP_Character to ALS Character BP
  • Restore all the defaults by clicking Show Only Modified Properties and then clicking the little left arrow for each of the ALS related components
    image
    image
  • Assign the animation blueprint reference on the Mesh component to ALS_AnimBP_C

During construction time, we can see that the StaticMesh, SkeletalMesh, and RootObject references are set:

image

But between then and BeginPlay, where UpdateHeldObject occurs (which is implemented in blueprints as calling ClearHeldObject), the meshes are somehow unset.

Note that the unique ID is the same:

image

Resulting in a null pointer exception.

Things to note

  • Besides the addition of the UniqueID property, the source has not been modified in any way
  • I don't observe this behaviour when subclassing the ALSCharacter C++ class directly (but that has other issues since many of the required properties aren't set, it won't crash on start at least)
  • The issue will occur regardless of the run settings (in all of Offline, Client, and Listen Server) modes
@HeyZoos
Copy link
Author

HeyZoos commented Aug 16, 2020

So it turns out this was due to a blueprint corruption. I needed to delete and recreate the blueprint. Here are some relevant things I found. If you have a blank Details panel then this might help you:

image

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/28537-uproperty-member-vars-reset-to-null-by-objectinitializer

I take it from the context of that AnswerHub question that this object of yours is blueprinted? It seems as though the CDO for that blueprint was saved with a null component. Thus, after running the constructor, the defaults are copied over to your object and the component is nullified. You should be able to tell if this is the case by getting the object instance somewhere in your code and looking at it with the debugger.

Components should be VisibleAnywhere, VisibleInstanceOnly or VisibleDefaultsOnly, never editable. Components being pointers, an editable component means you can edit the pointer to the component itself rather than the contents of the component, for instance allowing the component to be nullified. Which might be what somehow happened here along the way.

If this theory is correct, in order to get rid of the nullified component, you'll have to get rid of the current blueprint CDO. Unfortunately where this CDO exists is something I'm not clear on. I think part of it is in the blueprint asset itself, and some derived data is also processed in the Derived Data Cache. Last time I've had issues with undesirable defaults saved to a blueprint CDO, I managed to clear it up by deleting the blueprint, deleting the DDC folders (Engine/DerivedDataCache + MyGame/DerivedDataCache) and then recreating.

https://community.gamedev.tv/t/sphere-collision-details-panel-not-visible/71343/4

TLDR; Replace the corrupt SprungWheel BP.

I had the same problem in 4.20.3. except when I changed back to UStaticMeshComponent, the details panel remained blank. even after restarting Unreal.

Then I realised I had to comment out the CreateDefaultSubobject lines, build, uncomment and rebuild, the details panel then appeared. and was able to keep them as UStaticMeshComponent. this tactic wouldn’t work for USphereComponent though. those panels would never appear.

Then I discovered I could make the details appear in some weird format by changing VisibleAnywhere to EditAnywhere. but I think some options were missing, like Simulate Physics, MassInKg etc. though it’s all jumbled around. maybe they are there somewhere. 😛

After countless re-compiles & engine restarts, I managed to get the USphereComponents to show somehow. but then the AxleWheelConstraint details wouldn’t show… what a mess.

After more digging. I learned that the issue is the BP is corrupting/failing to adapt to changes in the source files. So I created a new BP of the SprungWheel class and all was visible as it should be. Kinda ***** that we have to recreate the BP every time we add/change components. but at least it works.

@HeyZoos HeyZoos closed this as completed Aug 16, 2020
@dyanikoglu dyanikoglu added the invalid This doesn't seem right label Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants