- Home /
How come Physic Materials parameters appears to do nothing ?
Hi,
I've been trying to do a moving flat horizontal platform using a kinetic rigidbody but when I put another rigidbody based object on it, it slides. I tried creating a super sticky material and assigned it to both objects but changing any of the parameters does not seems to affect anything. I would like to stack up a tower of blocks on that moving platform without them falling down but still retain their physical behavior.
To reproduce the problem I created a simple scene where I have:
- One flat platform with a kinetic rigidbody
- One Cube with a rigidbody
- One Super sticky material which I assigned to both objects
- And this script on the moving platform:
public class Shake : MonoBehaviour {
void Start () {
}
void Update () {
float sinTime = Mathf.Sin(Time.time);
float cosTime = Mathf.Cos(Time.time);
transform.Translate(transform.right * sinTime * Time.deltaTime);
transform.Translate(transform.forward * cosTime * Time.deltaTime);
}
}
Should I add a force of some kind to the objects on the platform (the energy of the moving platform) ? I thought creating a super sticky physic material would have done the trick...
Thx for helping me
Answer by Chapter9 · May 15, 2010 at 04:43 AM
The solution couldn't be more obvious but just in case someone end up on this questions and can't find the answer, here it is...
According to Unity Rigidbody Documentation we need to use Rigidbody.MovePosition:
For kinematic rigidbodies it applies friction based on the motion of the rigidbody. This lets you simulate moving platforms with rigidbodies sitting on top of the elevator. If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function.
Answer by Chapter9 1 · May 12, 2010 at 09:45 PM
OK, I made a lot of tests and...
When the IsKinematic flag is enabled, moving the platform does not propagate the translation force of the moving platform on objects colliding with it since in Kinematic mode we are translating objects using transform.Translate and not using rigidbody.AddForce... which make sense... Surprisingly, the torque is still applied. Not sure if this is a bug or a feature...
Anyway there's is in fact two solutions for this:
The first one is to disable IsKinematic flag and gravity and start using rigidbody.AddForce instead of transform.Translate. Now, by doing that, this results in other problems when other objects collides with the platform but we can manage it by canceling their effects.
The second solution is to stay in Kinematic mode. By computing the delta translation between frames we could compute a force that would be applied on all colliding objects. Which would require to keep a list of objects and on...
I'm going to test theses solutions and see where it gets me... I'll post my findings.
p.s. I've heard about Unity 3.0 updating the PhysX engine... maybe there's a solution in waiting.