USD collision in 5.4

Hi, I’m trying UE 5.4.0, love the new stuff!
But I have a problem with enabling collision on imported USD asset.
I can import asset via Content Browser in 5.3.2 and enable Simple or Complex collision in Static Mesh editor.
If I open copy of same project in 5.4.0, the existing asset still has collision, but if I import a new USD asset using the same process I cannot enable collision on the new asset. Similar result using USD Stage Editor.
However I CAN import an FBX asset and enable collision on that asset.

Any advice welcome and apols if this is not the right place to post, only been using UE 3-4 weeks.

1 Like

What do you mean by you cannot enable collision?
By default you will not have collision set up for the simple collision, you will have to generate it in the static mesh editor.

In 5.4, support for collision was implemented, so UE can read collision from the USD file. This support was added through the implementation of the following schemas:

  • UsdPhysicsCollisionApi: to specify meshes/prims as colliders
  • UsdPhysicsMeshCollisionApi: to specify collision shapes on meshes/prims

Hello All.

I’m having the same problem.

5.3 works fine, I can generate simple collision in the static mesh editor with no problems and use complex as simple and everything works fine. However. in 5.4, a third person BP will only collide with a box simplified generated collision. Any other generated type will not work including using complex as simple.

AS 5.4 can read the collision file from the USD, for custom collisions that’s great but how does this get specified? Is it something in the USD exporter or can we simply build and name them correctly the way it works for fbx. At the moment I’m having no luck, so I’d appreciate any suggestions.

Thanks

Oh…I should also mention it doesn’t seem to matter whether the assets are on the USD stage or I import them in using the import on the stage window, I still get the same issue.

In 5.4

If you want to add collision you need to add the good schemas to your prim and then the token physics:approximation value and the physics:collisionEnabled boolean

over "pCylinder380" (
            prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]
        )
        {
            uniform token physics:approximation = "boundingCube"
            bool physics:collisionEnabled = 1

approximations values are
image

If you want to use another mesh as your collision mesh :

  • Meshes that represent collision shapes should be sibling from rendering mesh
  • These meshes should have the “guide” purpose
  • These meshes must use the “PhysicsCollisionAPI”, “PhysicsMeshCollisionAPI”. They should also use the none approximation
 def Mesh "Duck" (
        prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]
        prepend references = @Assets/Game/USD/Duck.usda@
    )
    {
        token visibility = "inherited"
        matrix4d xformOp:transform = ( (1, -0, 0, 0), (0, 1, -0, 0), (0, 0, 1, 0), (-80, -150, 20, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]
    }

    def Mesh "Box" (
        prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]
        prepend references = @Assets/Game/Box.usda@
    )
    {
        token visibility = "inherited"
        matrix4d xformOp:transform = ( (1, -0, 0, 0), (0, 1, -0, 0), (0, 0, 1, 0), (-70, -150, 20, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]
        uniform token purpose = "guide"
        uniform token physics:approximation = "none"
    }

    def Mesh "Sphere" (
        prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]
        prepend references = @Assets/Game/Sphere.usda@
    )
    {
        token visibility = "inherited"
        matrix4d xformOp:transform = ( (1, -0, 0, 0), (0, 1, -0, 0), (0, 0, 1, 0), (-50, -150, 100, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]
        uniform token purpose = "guide"
        uniform token physics:approximation = "none"
    }

The cube and sphere will be used as collision meshes for the duck

Thanks UE_FlavienP for your detailed answer regarding importing collisions from the usd file. But, what about simply creating them in the static mesh editor? This used to work in 5.3, and in your original answer to norv2001 I got the impression it should still work. I’ve attached a couple of images below to illustrate the problem (sorry about the large size)

In the first image you can see I have auto generated a simple collision but this is completely ignored. In the second image I’ve generated a simple box collision and this works. As you can see I’ve reset the collision preset on the instance because this always defaults to no collision now, and I’ve set it to block dynamic in the static mesh editor. In 5.4 the only generated collision that appears to work is the simplified box and it doesnt matter whether its on the USD stage or if you import the stage to the project.

If I’m missing something really obvious, my apologies, but like I say this works in 5.3.

Thanks for your help


1 Like

Apparently it is linked to that option that is ticked in the static mesh details in 5.4. I will check with Dev why did it changed.

Edit: Now that you can specify if a part has collision we actively deactivate some settings if the collision info is not present in USD. Hence the collision preset change and the Never Needs Cooked Collision Data.

1 Like

Ah, OK. Thanks for looking into it. Got it working now.

I’m reading up on this topic with the hope that I can make the USD Importer auto enable collisions for me. Specifically, I just wanted to change the collision preset from “NoCollision” to “BlockAllDynamic”. Would these schemas accomplish this, and if so, how or where do I add these?

First you need to add the
prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]

to enable collision and it picks the BlockAllDynamic preset

then you will probably want to pick a physic approximation so UE computes a simple collision shape to use
uniform token physics:approximation = "convexHull"

Hello, currently facing the same issue as the ones mentioned above. Thank you for the suggestions UE_FlavienP.

I am currently editing my usda file with the code you wrote above and in my case I want to set my mesh definition to have collision enabled with a simple box collision

def Xform "Floor_119"
{
    matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (-9, -4.76837158203125e-7, 0, 1) )
    uniform token[] xformOpOrder = ["xformOp:transform"]

    def Mesh "FloorMesh"
    {
	    prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsMeshCollisionAPI"]
		
        float3[] extent = [(-3, 0, -0.31380272), (0, 3, 0)]
        int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
        int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 7, 6, 6, 7, 5, 4, 4, 5, 1, 0, 2, 6, 4, 0, 7, 3, 1, 5]
        normal3f[] normals = [(-0.99999994, 0, 0), (-0.99999994, 0, 0), (-0.99999994, 0, 0), (-0.99999994, 0, 0), (0, 0.99999994, 0), (0, 0.99999994, 0), (0, 0.99999994, 0), (0, 0.99999994, 0), (0.99999994, 0, 0), (0.99999994, 0, 0), (0.99999994, 0, 0), (0.99999994, 0, 0), (0, -0.99999994, 0), (0, -0.99999994, 0), (0, -0.99999994, 0), (0, -0.99999994, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1)] (
            interpolation = "faceVarying"
        )
        point3f[] points = [(-3, 0, -0.31380272), (-3, 0, 0), (-3, 3, -0.31380272), (-3, 3, 0), (0, 0, -0.31380272), (0, 0, 0), (0, 3, -0.31380272), (0, 3, 0)]
        bool[] primvars:sharp_face = [1, 1, 1, 1, 1, 1] (
            interpolation = "uniform"
        )
        texCoord2f[] primvars:UVMap = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.375, 0.25), (0.625, 0.25), (0.625, 0.5), (0.375, 0.5), (0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.125, 0.5), (0.375, 0.5), (0.375, 0.75), (0.125, 0.75), (0.625, 0.5), (0.875, 0.5), (0.875, 0.75), (0.625, 0.75)] (
            interpolation = "faceVarying"
        )
        uniform token subdivisionScheme = "none"
		
		uniform token physics:approximation = "boundingCube"
		bool physics:collisionEnabled = 1
    }
}

However, I get a syntax error pointing at the prepend apiSchemas = [“PhysicsCollisionAPI”, “PhysicsMeshCollisionAPI”]

if I remove it and reload the usd file in the stager it imports fine and even shows the options in mesh definition
image

But because theres no physics schemas, it still doesnt create any sort of collision - I saw that your suggested code and what I see in my text editor seem to differ a bit in syntax, so is there any specific place where I should add the prepend line for it to work?

Thank you in advance!

Did you figure it out

Hi, my name is Ovi, I am FX Artist in Houdini FX, I try to add one animated USD and rto have the proper collisions on this usd. For static meshes works fine but I am wondering for animated meshes as usd if is one solution? I Apreciate. Thanks.