Collision shape not scaling, but the mesh does? (Pictures included.)

138189-ue4-screenshot19.jpg

As you can see in the above images, the ball’s mesh scaled, but the collision shape did not, and now the mesh goes through the walls and floors. How can I get the collision shape to scale?

I believe you need to call RecreatePhysicsState on it after scaling it. This function isn’t accessible via Blueprint so you have to add it to some C++ function library that you create. The body is VERY simple. Just have take in a UActorComponent pointer and do this (call it whatever you want, of course):

In the header

UFUNCTION(BlueprintCallable, Category = "Physics")
static void RecreateComponentPhysicsState(class UActorComponent* pActorComponent);

In the cpp

void UYourFunctionLibrary::RecreateComponentPhysicsState(UActorComponent* pActorComponent)
{
    if (pActorComponent != nullptr && pActorComponent->IsValidLowLevel())
    {
        pActorComponent->RecreatePhysicsState();
    }
}

Hmm, that didn’t seem to work. Are you absolutely sure this will fix the problem? Or did I do something wrong? I’m brand new to adding C++.

I added a new C++ actor component to my blueprint, copied and pasted the code above to the bottom of the pages in Visual Studio, saved all, and added the new node to the blueprint after calling the scale.

It would be easiest if you posted your project (assuming it’s small enough and you’re comfortable sharing it) or a new project with JUST this issue so we can see exactly what you’re doing differently. You can share a zip of your project (which will include all content + source for that project) via File → Package project → Zip Up Project.

Here’s a sample of a project (4.14.3. I don’t have 4.15 installed on this computer but can check it tomorrow on one that has it) that doesn’t show the issue happening and without calling RecreatePhysicsState(). (Press ‘P’ to scale the spheres to 3.0 and notice their collisions are still valid, with and without simulating physics) If you want, you can use this zip as a starting off point to reproduce the issue then share that instead of your project.

Small sandbox project

I’ve run into this issue before when doing non-standard setups involving parenting and unless you have your actors/components setup differently from my expectations, the above is how I fixed it.

If you are working this as BP only, I’m pretty sure that turning physics off and on again does the same thing as RecreatePhysicsState. I had an issue with physics after scaling and that worked for me.