Then I’m grabbing pre-made cubes that are in the scene and I move them so that they should hit the procedural cube; except that they don’t, they pass right through it.
If I grab the procedural cube and move it around, it doesn’t hit anything. If I enable “simulate physics” on the procedural cube, it just fall through the ground.
I have not verified this assumption, but here is what I think: You set bUseComplexAdSimpleCollision = false, which means you are telling the engine to not use the visible mesh as collision, but instead some special collision geometry, that is made up of primitives. But you don’t provide that. You only provide the geometry, but you tell the engine not to use it for collision. So the engine is left with nothing to calculate collision. If you set this to true, it might work.
Actually you’re right, if I set it to true then if I grab pre-made cubes and throw them to the procedural cube they get blocked!
But there is a reason if I set it to false: if I try to simulate physics on the procedural cube, then it throws me this error and it doesn’t simulate anything:
PIE:Warning: Warning Trying to simulate physics on ‘’/Game/FirstPersonCPP/Maps/UEDPIE_0_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.BP_MyActor.UCustomProceduralComponent’’ but it has ComplexAsSimple collision.
LogPhysics:Error: PHYSX: (d:\build++ue4+release-4.14+physx_compile\sync\engine\source\thirdparty\physx\physx_3.4\source\physx\src\NpRigidBodyTemplate.h 479) eINVALID_PARAMETER : RigidBody::setRigidBodyFlag: dynamic meshes/planes/heightfields are not supported!
How can I solve this so that I can simulate physics AND have the procedural cube collide with other things?
A second wild guess Simulating physics only works when the physics engine knows about a mass of an object. Since you just provided vertecies and triangles the engine may not know what mass your object has. Have you tried to use the mass override in the details panel of your mesh istance, and just set it to 100 or whatever?
Actually I discovered a method of UProceduralMeshComponent called “AddCollisionConvexMesh”, which takes the list of vertices that compose the collision shell basically. That plus the bUseComplexAsSimpleCollision boolean set to false will make the procedural objects behave like they should.
To make the cube behave like any object now I just call that method after creating the section and I pass the vertices of the section to it.
Although it still interests me if the above would work. The AddCollisionConvexMesh probably provides a primitive, of which the mass is known. Can you just try out if it works with the mass override (I may need that in the future myself :D)
Sure! I tried but it doesn’t work, it keeps throwing me the errors I mentioned above.
The thing goes probably like you said: with bUseComplexAsSimpleCollision set to false the engine needs to know the shape of the object, and that’s what AddCollisionConvexMesh() is for. With the boolean set to true it works for simple collisions only (meaning that other objects can collide with the cube), while it’s not enough to simulate physics.