reepblue Posted March 19, 2019 Share Posted March 19, 2019 I'm looking into ways to re-create my floor buttons I've used in the Vectronic Demo. I don't want to rely on triggers this time around but instead have it be reactive to live physics. Here is a rad picture of how I intend to do this, The idea was to have a slider with a spring attached to prevent the slider joint from collapsing on itself. To test if the button was pressed, I would test the distance from the top model to the base entity. I've tried this with 4.5 and the top kept bouncing. The only thing that worked was using a Kinematic joint, but I couldn't lock it to an axis. I haven't tried this in months, but what would be the best way to go about this and is this do-able in the engine. I hate to ask for help without providing code, but I don't have my attempts anymore. 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted March 19, 2019 Share Posted March 19, 2019 There are new spring parameters that might help with this: https://www.leadwerks.com/learn?page=API-Reference_Object_Joint_SetSpring It sounds like in your case increasing the damping value might help. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 19, 2019 Share Posted March 19, 2019 Also, if the button does not move around in the scene you can make the parent entity NULL. This doesn't really matter in terms of behavior but it might make life simpler. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted March 19, 2019 Author Share Posted March 19, 2019 I'll give this a go tonight and let you know how I make out. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Solution reepblue Posted March 26, 2019 Author Solution Share Posted March 26, 2019 It's a start, might need adjusting later but this is great for VR push buttons. function Script:Start() self.entity:SetMass(1) self.entity:SetGravityMode(false) local position=self.entity:GetPosition(true) self.joint=Joint:Slider(position.x,position.y,position.z,0,-20,0,self.entity,nil) self.joint:EnableLimits() self.joint:SetLimits(0,1) -- The lower the number, the shorter distance. self.joint:SetSpring(1000,1000,self.entity:GetMass()) end function Script:UpdateWorld() if self.joint:GetAngle() >= 0.1 then System:Print(self.joint:GetAngle()) end end Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
reepblue Posted April 2, 2019 Author Share Posted April 2, 2019 Just putting this info here in-case someone looks this up: Add an additional sub-step to prevent the spring from "freaking out" when down. world->Update(2) Current code that's working very nice. function Script:Start() self.entity:SetMass(1) self.entity:SetGravityMode(false) local position=self.entity:GetPosition(true) self.joint=Joint:Slider(position.x,position.y,position.z,0,-20,0,self.entity,nil) self.joint:EnableLimits() self.joint:SetLimits(0,0.02) self.joint:SetFriction(1000,1000) self.joint:SetSpring(2500,2500,50) end function Script:UpdateWorld() if self.joint:GetAngle() >= 0.01 then System:Print(self.joint:GetAngle()) end end Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! 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.