nathank Posted December 12, 2011 Posted December 12, 2011 What would be the best way to lock an object so it can only move along one axis? I want something to fall by gravity along z, but stay at exactly the same x and y coordinates.
ulf.schroeter Posted December 12, 2011 Posted December 12, 2011 From within worls script flush() methode get current object X/Y/Z position, replace X/Y values with your fixed values and that explicitly set object position.
nathank Posted December 13, 2011 Author Posted December 13, 2011 That doesn't seem right. If I mess with the absolute position of the object I just end up fighting the physics engine and the gravity doesn't work properly. The object just jutters slowly downward, never picking up any speed. Shouldn't I be modifying some phsics based property? I've also tried doing what u suggested with get/setLinearVelocity and also attempted to apply an opposite force with addForce, but neither of these seem to have any effect.
ulf.schroeter Posted December 15, 2011 Posted December 15, 2011 There will be new BodyRail and JointRail physics objects in the upcomming SDK release. Maybe these can also be used for your use-case.
manguste Posted December 27, 2011 Posted December 27, 2011 For your purpose you can use JointPrismatic (constrains both movement and rotation) or JointCylindrical (if you do not want to constrain rotation).
nathank Posted December 28, 2011 Author Posted December 28, 2011 I've been playing around with the prismatic joints on and off for a few days and have almost convinced them to do what I'm after. Struggling to get all the parameters right though. Could you please clarify what effect linear softness and restitution have on the joint?
manguste Posted February 6, 2012 Posted February 6, 2012 I've updated function descriptions (see Joint class). In brief, restitution and softness together control the rigidity of a joint. Rigidity determines if the joint snaps bodies into place or they are drawn back gradually. This parameter controls how fast the joint tries to restore coordinates of the bodies. Softness allows the joint to be like a jelly: you touch one body and the second body on the other side also gets moving. This parameter determines if the joint tries to equalize velocities of bodies it is connecting.
nathank Posted February 19, 2012 Author Posted February 19, 2012 I have got the joints working. I thin my original problem was that the anchor wasn't in quite the right spot. Thanks for the clarification of those parameters though. Makes more sense now.
Recommended Posts