I found an old question posted about this but he never received an answer. Basically I had to dynamically create components to add to an actor instead of using the constructor. When my character walks over the new floor component he gets stuck and cannot move. I can still jump but cannot walk across the surface. The collision also does not seem to work properly as projectiles will pass right through the object. I’m thinking its a collision setting or somehow the new object was not properly set up. I did not experience this when I used the constructor. Here is the original post:
I’ve tried changing the collision settings but to no avail. Below is the code and I would greatly appreciate help as this has really got me stuck…Literally.
//Add Base
SpawnLocation = FVector(0, 0, BBaseFloorY);
BaseActor = World->SpawnActor<ABuildingClass>(BaseClass, SpawnLocation, FRotator::ZeroRotator, SpawnParams);
UStaticMeshComponent* BaseFloorMeshComp;
UStaticMesh * BaseFloorMesh;
BaseFloorMesh = LoadObjFromPath<UStaticMesh>("StaticMesh'/Game/Objects/BuildingGroundFloor.BuildingGroundFloor'");
BaseFloorMeshComp = NewObject<UStaticMeshComponent>(BaseFloorMesh);
BaseFloorMeshComp->SetStaticMesh(BaseFloorMesh);
BaseFloorMeshComp->SetOnlyOwnerSee(false);
BaseFloorMeshComp->bCastDynamicShadow = true;
BaseFloorMeshComp->CastShadow = true;
BaseFloorMeshComp->SetRelativeScale3D(FVector(BScale, BScale, BScale));
BaseFloorMeshComp->SetMobility(EComponentMobility::Movable);
BaseFloorMeshComp->BodyInstance.SetObjectType(ECC_WorldDynamic);
BaseFloorMeshComp->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
BaseFloorMeshComp->BodyInstance.SetEnableGravity(true);
BaseFloorMeshComp->BodyInstance.SetResponseToAllChannels(ECR_Ignore);
BaseFloorMeshComp->BodyInstance.SetResponseToChannel(ECC_WorldStatic, ECR_Block);
BaseFloorMeshComp->BodyInstance.SetResponseToChannel(ECC_WorldDynamic, ECR_Block);
BaseFloorMeshComp->BodyInstance.SetResponseToChannel(ECC_Pawn, ECR_Block);
BaseFloorMeshComp->bOwnerNoSee = false;
BaseFloorMeshComp->AttachTo(BaseActor->GetRootComponent());
BaseFloorMeshComp->RegisterComponentWithWorld(GetWorld());