Dear Friends at Epic,
In Beta4 and Beta5 I would do the following all the time
all in C++ constructor for a Character , which of course is instanced in-game using BP
- get the static mesh asset via path
- create the static mesh subobject
- set the mesh
- add this static mesh sub object to a Socket
final step
go into editor and compile the BP, even if it checkmarked as green, to cause a compile and make the component added in c++ appear.
Now in Beta6
I can do all but the step of adding to a socket
if I also add the native component to a socket in the C++ constructor
then when I go into the Editor, the component does not appear even after clicking the compile button!
I’ve tested this numerous times.
#General Comment
Adding Components via C++ has never worked properly for me, starting with Beta4, they never appear in game until I go into the Editor and recompile the blueprint, and the blueprint does not indicate it knows it is missing a component, but the editor does crash if I do not write out the .cpp part, so it does know it is there.
But I have to click the already-green compile button to get the comp to appear.
this was true in Beta4 and Beta5
But now in Beta6
#UE4 is losing support for adding Static Mesh Components via C++
I consider this a severe bug
because I add components via C++ for a reason
Via c++ I am adding and removing armor and weapons from character mesh sockets, weapons that are part of the Character
It is the most efficient way to set up such an weapon/armor inventory
rather than making instanced actors for each weapon and attaching actor to actor (ridiculously less efficient and much more confusing)
I need to be able to add static mesh components via C++ for UE4 to be functioning for my game’s needs.
#My Previous Thread on This Issue
Have to click already-green checkmark for adding new Native Components
https://rocket.unrealengine.com/questions/6839/staticmeshcomponent-added-in-c-only-shows-after-cl.html
this is true for static mesh as well as skeletal mesh components
#Repro
create a static mesh sub object in c++ for a Character similar to this:
#.h
This is an ACharacter Class
//ArmoredView
TSubobjectPtr ArmoredJoyfulView;
UStaticMesh* AssetSM_ArmoredView;
FORCEINLINE void SetupSMComponentsWithCollision(UStaticMeshComponent* Comp)
{
if(!Comp) return;
//~~~~~~~~
Comp->bOwnerNoSee = false;
Comp->bCastDynamicShadow = true;
Comp->CastShadow = true;
Comp->BodyInstance.SetObjectType(ECC_WorldDynamic);
Comp->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Comp->SetHiddenInGame(false);
}
#.cpp
//Constructor
//Asset, FROM CODE (cannot use BP since BP properties not valid till after constructor)
static ConstructorHelpers::FObjectFinder StaticMeshOb_AW(TEXT("StaticMesh'/Game/VictoryGoals/Mechs/Windturtle/Upper/WindTurtleArmoredView.WindTurtleArmoredView'"));
AssetSM_ArmoredView = StaticMeshOb_AW.Object;
//Create and Add
ArmoredJoyfulView = PCIP.CreateDefaultSubobject < UStaticMeshComponent > (this, TEXT("Happy1"));
Components.Add(ArmoredJoyfulView);
//Set Mesh
ArmoredJoyfulView->SetStaticMesh(AssetSM_ArmoredView);
//Setup (see .h)
SetupSMComponentsWithCollision(ArmoredJoyfulView);
//Attach to socket
//ArmoredJoyfulView->AttachTo(Mesh, FName(TEXT("ArmoredView")));
//If I uncomment this, the component disappears from the Editor BP of this Character,
//and I have to change the name of the subobject to get it to appear again.
Then you can go into the editor and try to add the component.
It should appear,
but then go back and uncomment the line with the adding to socket,
and recompile the C++
and then recompile the BP in the Editor
at this point the component disappears, for me, in Beta6.
#Is the Asset Being Found?
Yes, please, I checked that
#Please Help
I am seeing support for native static mesh components deterioriating, not improving
Rama