- Home /
How can I fake buoyancy (floating) with a configurable joint (or with a script)?
I already checked out a "real" buoyancy script, and determined I don't want that. Large, flat objects are likely to fly up in the air and/or spaz out, and when it does work, they are too easily overturned. So I want to fake it.
But I can't configure the configurable joint to do what I want it to- act like a raft. You jump on it, it sinks a little then returns to a lower resting point- jump off, it bounces back up and settles to its original position. This by itself shouldn't be hard to do, but I also want it to tilt slightly toward the edge you're standing on if you are standing off center.
So I want its translation tightly limited, in a springy way, along the Y axis; and its rotation even more tightly limited, in the same springy way, on the other two axes.
Or putting it another way- it should be able to move freely in the xz plane and rotate freely around its y axis but be otherwise spring-constrained.
I don't know why but I can't configure a configurable joint to get this behavior. Or any behavior I'm trying to get from it for that matter.
I'm dropping a rigidbody cube on it to test it and my raft always just sinks, no matter how I have the joint set up. And it rotates as it is sinking, even if I set the x and z rotation to "locked." I just don't get it.
I figured out my main mistake, which was setting the axis to Y. Which is what I think should be right, but if I set it to X the vertical floating works, and if I set it to Y, it doesn't.
Answer by Kiloblargh · Mar 31, 2010 at 08:45 PM
Figured it out, so I need to answer my own question:
Axis X, secondary axis 0 Xmotion: Free Ymotion: Limited Zmotion: Free
Xmotion: Limited Xmotion: Free Xmotion: Limited
Linear limit 0, 0.2, 3, 1
High Angular XLimit: 0, 0.4, 3000, 0.2,
Angular Z limit: Same as above
Rotation Drive Mode: Slerp
Slerp drive mode: position
Spring: 8 Damper 0.8
And it's working! Main issue is that the spring on the rotation has to be so much higher than the spring on the translation, and the axis confusion was what was keeping the joint from working at all.
Answer by duck · Mar 31, 2010 at 07:27 PM
Have you seen this answer?
It describes a method which results in stable floating raft-like platforms. It doesn't use a configurable joint though. I don't think a configurable joint is really a good fit for this problem.
Answer by wishing · Aug 24, 2010 at 02:39 AM
Hi, im sorry but i dont really understand your answer. can you answer it in a more scripting way? im really bad at scripting.
I think you mean to Comment, not "Answer". And the above is not scripting - it's saying what values to set on the ConfigurableJoint - i.e. you don't have to script anything.
Your answer
Follow this Question
Related Questions
Allowing player to swim or dive in water? 6 Answers
Calling OnJointBreak on Connected body 1 Answer
Water physics in solid object 2 Answers