I created a script that takes the vertices of the capsule to be able to divide its positions on the z axis by two when I press the letter C, so far so good, it worked perfectly. But I’m having a problem with Character physics, it “drips” when I use this script on it. Does anyone know if I can solve this?
With Character physics:
Eat Physics Dynamics (No Sleeping disabled):
With Dynamics physics (No Sleeping enabled):
Note: I execute, in the first frame after I press the “C” key, and in the first frame after I release the “C” key. I update the mesh physics with “obj.reinstancePhysicsMesh ()” in the same way.
Notice how the object is static on the X and Y axes - only the Z axis is affected negatively.
I guess that is beacuse you are not taking the origin of the object into account.
If the origin of an object is in the middle, and you lower the scale on the Z axis, then the object will float in mid air - and if it has physics enabled, that will make it fall down.
When you scale it back up again, it clips through the floor - but the physics engine hides this from you, by teleporting the object above the floor again.
In order to remove the “drip”, change the object so that the origin is at the bottom, instead of at the middle - this way, when you scale it, it does not change its location on the Z axis.