How can I push down an object from another objects weight?

Here’s what I mean.

Let’s say I have this rectangular box, and if my character were to jump on it, the box will be pushed down and depending on the weight, the pushing speed will be increased.

How can I go about this?

2 Answers

2

One way is to let Unity’s physics system do the work. This only works if the player is a rigidbody (and not a character controller.)

Set the box as a rigidbody, but click on constraints for x,z and all rotations. Just leave Y. Now it can only fall, staying perfectly flat.

Then add a spring joint connected to nothing. It takes a bit to play with the springiness. At first, it will always drop a bit, making it tough to have it start where you wanted.

When the player lands on it, Unity will automatically lower and bounce it, based on player weight. When the player leaves, Unity will pop it back up, with a little jiggle (like a spring was underneath.)

Whoa that is so freaking Awesome. Thanks I never knew Unity had this springy thing. Awesome thanks.

First thing to note is this is not natural physics behaviour.

To achieve simply add a force based on the mass of your rigidbody