MisterGravity Posted January 15, 2014 Share Posted January 15, 2014 That may be the dumbest question ever. But seriously, I've been playing with these settings for 30 minutes now! How do you make a door swing like a regular door that's not from the Twilight Zone? Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
YouGroove Posted January 15, 2014 Share Posted January 15, 2014 Tested several times, it don't work and the code can't work with any door as it creates is own Joint : --Create a motorized slider joint local position=self.entity:GetPosition(true)+self.offset Instead we should use a script using one or two pivots we would place as child of a door that would say around what points the door rotate. I will try to make teh script. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
MisterGravity Posted January 15, 2014 Author Share Posted January 15, 2014 I'm pretty sure no one responded to the original request with the exact numbers because no one in the history of Leadwerks has ever gotten a door to swing open like a door in the real world. 1 Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
YouGroove Posted January 15, 2014 Share Posted January 15, 2014 I agree, nobody uses it. You can look at Hinge command reference that has a Lua example. It seems to work, i didn't succeed to make a script from it for the door. But the best way would be to havea door with a pivot as child where the Hinge should be and a script for the door. You should ask to skilled math programmers here Quote Stop toying and make games Link to comment Share on other sites More sharing options...
MisterGravity Posted January 15, 2014 Author Share Posted January 15, 2014 I agree, nobody uses it. You can look at Hinge command reference that has a Lua example. It seems to work, i didn't succeed to make a script from it for the door. But the best way would be to havea door with a pivot as child where the Hinge should be and a script for the door. You should ask to skilled math programmers here I didn't think of using a Hinge, that's a good idea. Take the rest of the day off. Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
Mordred Posted January 15, 2014 Share Posted January 15, 2014 maybe take a look in the tutorial map / Video about creating Switches and using the flowchart to link them to doors, i believe there's a Switch using the "Swinging Door" script and it's turning by 90 degree. Quote Link to comment Share on other sites More sharing options...
Mordred Posted January 15, 2014 Share Posted January 15, 2014 I'm sorry that i cannot post the link, but somehow IE doesn't like this Kind of frum..., Well tbh, i do not see any more in the Video as you already did MisterGravity In case you want to take a look, it's under documetation-tutorials-"Swiches and Doors" Quote Link to comment Share on other sites More sharing options...
MisterGravity Posted January 16, 2014 Author Share Posted January 16, 2014 Well, I never made a true swinging door, but I made a revolving door. Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
Interference Posted January 16, 2014 Share Posted January 16, 2014 Well, I never made a true swinging door, but I made a revolving door. You're not, by chance, using CSG to make the door are you? From what I can tell, you can't specify where a CSG brush pivots, so it will always rotate around it's centre of mass, causing a revolving door rather than a swinging one. If you attach the script to an imported model with it's pivot properly offset in your 3D software of choice to where you want the door to swing then THAT should work correctly. The only way around CSG not having it's pivot where you want is to place a pivot object in the right place and parent it to that. Quote Link to comment Share on other sites More sharing options...
MisterGravity Posted January 16, 2014 Author Share Posted January 16, 2014 You're not, by chance, using CSG to make the door are you? From what I can tell, you can't specify where a CSG brush pivots, so it will always rotate around it's centre of mass, causing a revolving door rather than a swinging one. If you attach the script to an imported model with it's pivot properly offset in your 3D software of choice to where you want the door to swing then THAT should work correctly. The only way around CSG not having it's pivot where you want is to place a pivot object in the right place and parent it to that. I just drew a door with the brush tool and gave it the swinging door script. Then when that didn't work after a considerable amount of time trying to tweak it, I accepted my failure and made it a revolving door. Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
Interference Posted January 16, 2014 Share Posted January 16, 2014 I just drew a door with the brush tool and gave it the swinging door script. Then when that didn't work after a considerable amount of time trying to tweak it, I accepted my failure and made it a revolving door. Well there you have it, then. It's because the pivot for the brush wasn't where it should be. Either model your door in a 3D package and set the pivot in that, or use a seperate pivot object. Quote Link to comment Share on other sites More sharing options...
Rick Posted January 16, 2014 Share Posted January 16, 2014 If you have a joint (which you can place anywhere and make a parent) you should be able move the join to cause the child door to move. I'll see what I can do tonight. This is far from impossible Just to give you some things to read on a way to do this. Check out http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/joint/jointhinge-r735 Using this joint is how you'd create a door on anything. CSG or not. Quote Link to comment Share on other sites More sharing options...
Mycekralid Posted January 16, 2014 Share Posted January 16, 2014 This cofiguration did it for me: door is 4.0 width and 0.5 thick. Offset is (4.0 - 0.5 - 0.5 / 2) / 2 (width - thickness of side wall - thickness of door / 2) / 2 Quote Link to comment Share on other sites More sharing options...
Rick Posted January 16, 2014 Share Posted January 16, 2014 There ya go I have to imagine this script uses the hinge which that is what it's pivoting around, not the csg center of mass or anything. 1 Quote Link to comment Share on other sites More sharing options...
Mycekralid Posted January 16, 2014 Share Posted January 16, 2014 Correction: (width - thickness of door / 2) / 2 I actually reduced the width of the door.... Quote Link to comment Share on other sites More sharing options...
YouGroove Posted January 16, 2014 Share Posted January 16, 2014 Can someone post a complete working script or example in asset store ? (for all people needing that) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Mycekralid Posted January 16, 2014 Share Posted January 16, 2014 its the standard script in "swinging door" under doors. Quote Link to comment Share on other sites More sharing options...
MisterGravity Posted January 17, 2014 Author Share Posted January 17, 2014 its the standard script in "swinging door" under doors. Followed your directions to a T! ...and no swinging door. But swinging doors? Who needs em? No big deal. 1 Quote I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience. Link to comment Share on other sites More sharing options...
CrazyM Posted September 8, 2014 Share Posted September 8, 2014 I know, old post, but I wrote this LUA swinging door script as an alternative to the built in script, and maybe someone else might find it useful. This script does not use a hinge joint, it assumes it's attached to a 3D model door with it's pivot point on the side where a normal hinge would go. Set a [1] on the rotation axis you wish to rotate, adjust the movement speed, the open/close angles, and link to optional open/close sounds. It also assumes your operating the door from the FPSPlayer script. Script.rotationAxis = Vec3(0,1,0) --Vec3 "Rotation Axis" Script.movementSpeed = 3 --float "Movement Speed" Script.closeAngle = 0 --int "Close Angle" Script.openAngle = 135 --int "Open Angle" Script.closeSound = "" --path "Close Sound" Script.openSound = "" --path "Open Sound" rotation = Vec3(0,0,0) moveDoor = false openDoor = false openSnd = nil closeSnd = nil function Script:Start() if self.openSound ~= "" then openSnd = Sound:Load(self.openSound) end if self.closeSound ~= "" then closeSnd = Sound:Load(self.closeSound) end end --FPSPlayer Use method function Script:Use() if openDoor == true then if closeSnd ~= nil then closeSnd:Play() end openDoor = false else if openSnd ~= nil then openSnd:Play() end openDoor = true end moveDoor = true end function Script:UpdateWorld() -- Stop movement if the open/close angles have been reached if self.rotationAxis.x == 1 then -- X rotation axis set if openDoor == true and self.entity:GetRotation().x >= self.openAngle then moveDoor = false end if openDoor == false and self.entity:GetRotation().x <= self.closeAngle then moveDoor = false end end if self.rotationAxis.y == 1 then -- Y rotation axis set if openDoor == true and self.entity:GetRotation().y >= self.openAngle then moveDoor = false end if openDoor == false and self.entity:GetRotation().y <= self.closeAngle then moveDoor = false end end if self.rotationAxis.z == 1 then -- Z rotation axis set if openDoor == true and self.entity:GetRotation().z >= self.openAngle then moveDoor = false end if openDoor == false and self.entity:GetRotation().z <= self.closeAngle then moveDoor = false end end -- Move the door towards it's selected position if moveDoor == true then if openDoor == true then -- Close door if self.rotationAxis.x == 1 then rotation.x = rotation.x + (Time:GetSpeed() * self.movementSpeed) end if self.rotationAxis.y == 1 then rotation.y = rotation.y + (Time:GetSpeed() * self.movementSpeed) end if self.rotationAxis.z == 1 then rotation.z = rotation.z + (Time:GetSpeed() * self.movementSpeed) end else -- Open door if self.rotationAxis.x == 1 then rotation.x = rotation.x - (Time:GetSpeed() * self.movementSpeed) end if self.rotationAxis.y == 1 then rotation.y = rotation.y - (Time:GetSpeed() * self.movementSpeed) end if self.rotationAxis.z == 1 then rotation.z = rotation.z - (Time:GetSpeed() * self.movementSpeed) end end self.entity:SetRotation(rotation) end end Quote CrazyMinnowStudio.com Youtube, Twitter, Facebook, G+ Link to comment Share on other sites More sharing options...
Thirsty Panther Posted September 8, 2014 Share Posted September 8, 2014 Bansama helped me with the same question here http://www.leadwerks.com/werkspace/topic/10226-where-can-i-find-this-example-map/ 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.