• Advertisement
Sign in to follow this  

How do I create a bouncy platform that stays flat?

This topic is 3868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm currently working towards creating a springy platform effect. Basically I want a platform which can bounce and shake if entities jump on it. So far, I've tried to solve the problem using Hooke's law: Force = (position vector of spring - position vector of platform) x some constant The spring effect works, but not when entities start bouncing on the side of the platform; my platform's center point will return to its original location (by spring action), but it does not rotate back into place. The platform stays slanted, as if it is only suspended by one rope in the middle. Question: How do I make the spring effect affect rotation, without creating additional entities or using API features? I know that the answer will have something to do with torque, but I don't know what the calculations should be.

Share this post


Link to post
Share on other sites
Advertisement
I guess I am curious....are you using a physics engine of some sort? I believe that you are....

So, there are a couple of possible solutions:

1) Do you only have a single spring at the center of the platform? Why not put four springs, all of equal stiffness (that "some constant" you mentioned), at the four corners of the platform (or at each corner if there are more/less than four)?

2) If you're using a physics engine, keep the 1 spring, but add rotational joint constraints that will keep the platform from rotating relative to the world. In PhysX, you could do this with an NxPrismaticJoint constraint (which would limit the springy platform to moving up/down only, with that single spring you have). With Bullet, you'd have to use a btGeneric6DofConstraint constraint.

Hope that helps!

Share this post


Link to post
Share on other sites
Yes I am using a physics engine, that does not have a spring function in-built.
What I'm trying to do right now is to create an effect of the platform having 4 springs on each corner, but I don't know how to calculate the net torque and net force.

There are no functions in the API which allows me to "apply force vector on object at so-and-so point"; the only available options are: "apply net force vector to object" and "apply net torque vector to object".

For a starter, I do not know which part of my rectangular platform should I use as a pivot in order to convert the 4 spring forces into torque for platform rotation. And even if I get the rotation by torque correct, I don't know how to calculate net force which is applied to the platform by the 4 springs. (e.g. if I use the 4 spring forces to produce torque, then where will the net platform force come from?)

Share this post


Link to post
Share on other sites
Torque is just (displacement from center of mass) cross (force). There should be some way to know what the center of mass of your object is (since the physics engine needs to know this to properly apply torques). Compute the displacement from the center of mass to where one of the springs is attached, then cross multiply that vector by the force vector of that spring, whose direction depends on the direction of the spring and whose magnitude is calculated using hooke's law or something similiar. Add up all these torques to get the net torque.

Also add together the forces from the springs as normal and apply the net force. It's a bit counterintuitive at first, but torque and force are computed independently of each other like this. If the platform is just rotated about its resting position, the forces will cancel out, and if it is just displaced from rest, the torques will cancel out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement