So we’re working on a simple game to learn the engine with a background in 3ds Max and Unity. In this game, we have a cash register full of bills and coins. We figured out how to lerp the bills into the drawer, but we want to drop the coins into the drawer with physics so we don’t have to place them manually and lerp each to a specific location and rotation.
However, we’re running into a lot of problems with these physics simulations. We’re not having issues with larger objects, so we assume these issues are caused by the physical size of the rigidbodies.
The coins are modeled to-scale with American coins, so they’re small and thin by nature. They all have “Use complex as simple” collision applied, though we’ve tried using auto convex collisions as well. In the first scenario, the coins will sometimes fall right through the register drawer and other times they will fall where they’re supposed to but won’t react like coins would; they just stack on top of each other. In the latter scenario, they seem to disregard coins under them as they fall and overlap, then shake for the rest of the game instance.
Of course, enable physics is turned on for each the coin classes’ mesh components. We put some linear damping on each of them because at first they were falling too fast for our tastes (not to mention, often falling straight through the drawer!). The register itself does not have enable physics, but has “use complex as simple” set for its collision.
Is there anything we’re missing here? Is there any more information I could give that could be helpful? Please and thank you for listening, UE4 community!
Update: I tried scaling the objects up and I’m having the same issues. I tried dropping the coins on the floor instead and I’m getting similar results: sometimes they land okay, sometimes they flip into the floor and disappear below it, as if the floor didn’t collide at all. I tried this with the mesh collision and with all the different simple collisions from the box colliders to the 26DOP, as recommended by siebencorgie. Same results.
I’m assuming this is because of the height of the coin because if I scale it up in Z and make it a super-thick coin, it collides just fine.
Thank you TJ, we have been mulling this option all day but we’re not sure about actually doing it because we plan to have other physics going on in-game, such as the hair on the cashier. It started as a learning project and now we want to flesh it out into a full game, haha. As it happens.
Would it be possible to scale the coins and register, run the sim and bake the whole thing into keys then scale the objects back down and play the baked animation back?
Alternatively, would it be possible to tweak some settings for bone-bound hair on hinge joints to compensate for the greater scale? Please and thank you!
You’re right, small object collision can be very odd. The best way to approach a game like this is to make the game much larger than real-life. The coins could be the size of frisbee’s (or even larger) and as long as the rest of the game is scaled the same, the player will not know the difference.
I just created a similar setup and it seems to work fine. Make sure you enable Use CCD (Complex Collision Detection) in the coins Details Panel. This will check the collision every tick and greatly lessen the chance of object clipping.
The first option isn’t possible to create ‘inside’ the editor, but you should be able to simulate and create an animation in your 3D modeling software that could work. You would just need to make sure that each coin has a bone assigned to it so it will work properly once it’s in UE4.
The second option is probably the way to go. When you are setting up the characters Physics Asset in the editor you should be able to tweak it to compensate for scale. Just make sure that you import your character at the scale needed. I would suggest doing some testing before committing to anything but it should be possible.
Awesome advice, TJ! It took a bit of work, but I was able to come up with a baked solution in 3ds Max and transfer that to UE4.
In case anyone is wondering, this is my workflow:
-Create mesh in 3ds Max
-Duplicate mesh to use as a bone, name mesh and bone accordingly. Don’t use regular bones because the bone must be set as a rigidbody with a custom convex mesh shaped like the coin itself.
-Skin the coin to the coin-shaped bone.
-Set bone as dynamic rigidbody with convex collider
-Select bone and coin together and shift drag up to create copies, I created 49 in this instance to have 50 total coins
-Randomize their locations and rotations if desired, best done through maxscript
-Set register drawer as static rigidbody with mesh collider
-Adjust simulation properties as needed to achieve desired effect during playback. I recommend bumping up the iterations and substeps since Max has issues with smaller objects as well if you don’t make it more strict.
-“Bake All” through MassFX options
-Reset XForms on coins and bones. If you don’t, your coins’ animations will be played back based on their local rotations/positions and you will end up with undesirable results in UE4
-Export Coins and bones but nothing else
-When importing in UE4, make sure to import animation in the skeletal mesh tab
-Create coins folder in scene outliner
-Filter out skeletal meshes in the content browser and drag em all in
-Put them in the folder just in case you want to affect them all at once
-Set all the coins to use an animation asset instead of an animation blueprint, turn of playing and looping
-Go through and set the corresponding animation asset on each coin (ugh there has to be a better way to do this)
-Play animations via blueprint or code
From my past testing it would appear that the physics scene may use single precision floats where as your 3D software probably exports mesh data as doubles. Naturally your larger objects have higher precision for their collision data. So it doesn’t matter how large you scale it up or down in unreal, it will always have the same precision based on the size when you imported it. My work around for this is to scale up your tiny physics objects but 10 or 100 times, export, then in unreal scale it down to the correct size. Your small objects will now behave as accurate as large objects. This works for me at least.
I was/am having difficulty detecting collision with anything less than 250 units squared. Tried your suggestion above, made a 10k sq box in 3DS Max, scaled down in UE, nothing. Anything less than 250 units square doesn’t block or show in hit results.