I have a mesh with a custom box collision that works as expected. The character can bump into and walk on it when I place it in the level manually. I don’t do anything to the collision just let it be the stuff I set up in the mesh. All is fine.
However when I spawn a mesh component in an actor at run time and set the mesh to be this mesh I cannot move while stood on the mesh. The character can still bump into it but if they are stood on it the can’t do anything but jump. So I kinda have to leap frog across these spawned in meshes.
I know there will be some setting I’m forgetting about for spawning a static mesh component but I can’t figure it out.
Here’s my spawn code:
for (int i = 0; i < NumPoints; i++)
{
Bridge.Add(NewObject<UStaticMeshComponent>());
Bridge.Last()->SetRelativeScale3D(FVector(0.2f, 0.2f, 0.2f));
Bridge.Last()->SetWorldRotation(FRotator(0.f, FMath::Lerp(-180.f, 180.f, FMath::FRand()), 0.f));
Bridge.Last()->SetupAttachment(Root);
Bridge.Last()->SetStaticMesh(BridgeMesh[FMath::Rand() % BridgeMesh.Num()]);
Bridge.Last()->RegisterComponentWithWorld(GetWorld());
SpawnPoint = FMath::Lerp(LeftSide.GetLocation(), RightSide.GetLocation(), (float(i + 1) / float(NumPoints + 1)));
Bridge.Last()->SetWorldLocation(SpawnPoint + ((FMath::VRand() * MaxRandDistance) * FVector(1.f, 0.f, 1.f)));
}
I have tried placing the mesh scaled in level and It works as I need it to so its not a scale issue.
I have toggled the collision visiblity so I can see that it is the same box as a placed mesh when I spawn it in.
The mesh collision profile is left on BlockAllDynamic.
If you need any more info please ask.