tipforeveryone Posted June 12, 2018 Share Posted June 12, 2018 I found this in default FPSPlayer.lua while testing Joint:Kinematic but had no idea what was it usage Quote Link to comment Share on other sites More sharing options...
gamecreator Posted June 13, 2018 Share Posted June 13, 2018 All I could find in the C header was that the first value is linear damping and the second is angular damping. There are a few examples on the forums of people using it. Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 13, 2018 Share Posted June 13, 2018 Sets the damping value of a physics body. Damping slows the velocity and omega each frame by a small amount. Example: window = Window:Create("Linear Damping Example",0,0,800,600,Window.Titlebar+Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetPosition(0,10,-6) camera:SetRotation(45,0,0) light = DirectionalLight:Create() light:SetRotation(35,35,0) ground = Model:Box(50,1,50) ground:SetPosition(0,-0.5,0) ground:SetColor(0,1,0) shape = Shape:Box(0,0,0, 0,0,0, 50,1,50) ground:SetShape(shape) shape:Release() box = {} for i = 1, 3 do box[i] = Model:Box() box[i]:SetColor(1-0.5*(i-1),-0.5*(i-1),.5) shape = Shape:ConvexHull(box[i]:GetSurface(0)) box[i]:SetShape(shape) box[i]:SetPosition(-8+i*4,1,0) box[i]:SetMass(1) box[i]:SetDamping(1-0.5*(i-1),1.0) end while window:KeyHit(Key.Escape)==false do if window:Closed() then break end if window:KeyHit(Key.Space) then for i = 1, 3 do box[i]:AddForce(0,0,1000,true) end end Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:DrawText("Linear Damping (from left to right): 1, 0.5, 0",2,2) context:DrawText("Press SPACE to apply the same force to all boxes!",2,22) context:DrawText("The higher the damping-value, the faster the box stops.",2,42) context:SetBlendMode(Blend.Solid) context:Sync(true) end 1 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
tipforeveryone Posted June 14, 2018 Author Share Posted June 14, 2018 Thank you @macklebee this is so clear ! I wonder why there are many functions like this not in document, maybe they are unofficial but still being used in default code somewhere, making everybody confused Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.