Download

How to make a floating Mesh inside BoxCollision?

Hi.

I have a StaticMeshComponent and a BoxComponent.

As you can see, the Hierarchy is BoxComponent as ROOT and StaticMeshComponent as a CHILD of the Box.

Now, when I place this Actor in the level in MID-AIR like this:

When I press Play, the StaticMeshComponent falls to the ground acting like a RigidBody, whereas the BoxComponent remains in mid-air!

I totally don’t understand why this is happening

What I want is the BoxComponent falling to the ground (without rotating, without simulating physics, without overturning… just linearly fall) AND the Mesh should follow the BoxComponent… and when the BoxComponent finally touches the ground, the Mesh has to remain in mid-air so that it doesn’t touch the ground too!

I hope I made it clear enough.

Thanks in advance!

Switch simulate physics *off *on the mesh, switch it *on *for the box. Set box’s collision to block. You can adjust constraints in the box’s physics tab.

If you do not wish to use physics, you’ll need a different method for movement. You can interpolate during tick until you touch ground via line tracing.

Thank you for the answer, I appreciate your help.

I set the Mesh Simulate Physics to OFF, the Box Simulate Physics to ON
But when the game starts, the Mesh merely falls on the ground

These are the **Collision Settings for the Mesh

**

And these are the Collision Settings for the Box

~ Show Collision

to see if box is around mesh when it falls

Yes, the Box **is **around the Mesh.

wwww.jpg

But I want my Mesh to *float in mid-air *inside the box, not touching the ground

Just to be sure, that what you need, right:

https://gyazo.com/f95a3a10974677dc9f759b3b46e32123

Capture.PNG.jpg

The box collision:

cap2.PNG

The floor is at defaults, meaning its collision is set to *Block All *and it’s a *Static *object Type. The above box is a dynamic object that responds to Static.
The mesh collision is only important for any further interaction and should play no role here.

That is exactly what I want to achieve… you seem to get it work, but I don’t!

Here are my screenshots updated:

**Mesh Collision

**

**Box Collision

**

The only difference between your BoxCollision and mine, is that mine enables Overlap for the Pawn (this is a Pickup)

It works now!

One thing though I’d like to fix is the bouncing. My Mesh bounces when it touches the ground… and your cone does too!

I want the Mesh to just fall and stop. Any ideas about this one?

In box’s collision panel Enable Simulation Generates Hit Events (the very top of my previous screenshot) and do this for the box:

Capture.PNG

As soon as it hits something, the physics is switched off. Since you do not want physics anyway - this might be the best solution.

First of all, I don’t have any **Simulation Generates Hit Events **in the BoxCollision details (my screenshots above are a demonstration of what I see)

I’m using C++ to create the Components and this is the code



    CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));
    CollisionBox->SetSimulatePhysics(true);

    // Setup the pickup mesh
    PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
    PickupMesh->bCastStaticShadow = false;
    PickupMesh->CastShadow = false;
    PickupMesh->bCastDynamicShadow = false;
    PickupMesh->SetSimulatePhysics(false);

    RootComponent = CollisionBox;
    PickupMesh->AttachTo(RootComponent);


However, I tried to use the **OnComponentHit **event as you said and a PrintString node actually confirmed me that the event is not fired. Looks like it wants the **Simulation Generates Hit Events **enabled, but I have no idea where to find that option

Search for Notify Rigid Body Collision.

**THAT **was so subtle. I could have never come up with that.

Thank you very much for your support. Thank you very much.