- Home /
How to get movable/pushable cubes right?
In my scene, I have two cubes at the default scale of 1 x 1 x 1. One of them is a "player" cube and the other is a "movable" cube that the player can push around on the floor.
The movable cube prefab has the following attributes:
And a few notes that I observed when moving these cubes:
When pushed by the player the cube would start spinning, so I restricted the rotation as shown in the above image.
I noticed that the cube initially just shot out the direction it was pushed, so I tried increasing its mass and drag, but a high value of drag would cause the cube to NOT fall off the edge of the floor, which is not what I want. So, I assigned "0" to drag for now.
Another annoying thing is that sometimes the cube appears to be stuck on the floor when the player pushes it from certain directions. I don't know if indeed it has to do with the direction from which it's being pushed, but pushing the same cube yields some erratic behaviors. Odd thing is that when a NavMesh agent runs into the cube, the cube gets pushed aside quite naturally, but it is when the player pushes the cube the result is either hit or miss.
Essentially, I need the movable cube to be pushed around without getting stuck every so often. Also, I need it to react to the gravity as in real life (like falling off the edge when more than half of its body is off the floor), and when it is pushed it shouldn't move too far out - maybe just the length of its own size or a bit more would be perfect.