SlipperyBrick Posted September 19, 2016 Share Posted September 19, 2016 Hi Guys, I am wanting to program some door physics in the same style as how the doors work in the game Amnesia. For those who haven't played Amnesia: The Dark Descent you click and hold on a door and then drag in a certain direction to open it, releasing the mouse at the peak of the drag. The speed of the drag defines how far the door will open in combination with how fast you dragged and when you left the mouse click go. How would I start something like this and is it even possible in Leadwerks? To start off simple, how would I even get an object to rotate at a certain point, could I attach a pivot to the object in question in the precise location I want my rotation origin and then have my door.lua or whatever attached to that pivot? It would be awesome to adapt on the script so you can put a file path for an object rather than doing this with something like a prefab. Quote Link to comment Share on other sites More sharing options...
Genebris Posted September 19, 2016 Share Posted September 19, 2016 You just need joint class. http://www.leadwerks.com/werkspace/page/api-reference/_/joint/jointhinge-r735 http://www.leadwerks.com/werkspace/page/api-reference/_/joint/jointsetangle-r799 1 Quote Link to comment Share on other sites More sharing options...
mdgunn Posted September 20, 2016 Share Posted September 20, 2016 There is a workshop item for this. If it works like how you want. Don't have link right now got to rush out to work. Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 20, 2016 Author Share Posted September 20, 2016 I'll have to check that out. I tried using the Hinge.lua script last night but couldn't figure out how to get it to work. I have a pivot as a parent to the object I want the rotation to work with and I put the Hinge.lua script to that pivot. Not to sure if that's how it works. I'll look in to the Joint class too, I am using the FPSPlayer script for my character at the moment. I need to go through the script to see how the use function works and to check what else is in the script. I did try starting my own FPSPlayer script but it just seemed a bit to much work considering there is already one available lol Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 22, 2016 Author Share Posted September 22, 2016 Any answer to this guys? I've tried to Google some tutorials but didn't really find much in regards to video's or answers. I'm not to sure how the Joint class works. Would it need to be attached to a pivot and that pivot parented to the object that is going to act as the rotation point? This seems the most logical answer yet when I actually try it, it doesn't do anything lol. I'm not to sure if I need to change anything in the FPSPlayer.lua to get this to work though. There already is a method in FPSPlayer.lua for using item's/picking up items, that is binded to the E key but this doesn't seem to do anything either. Quote Link to comment Share on other sites More sharing options...
Angelwolf Posted September 22, 2016 Share Posted September 22, 2016 Ive never tried this but I have an idea. Make a pivot for a hinge and add the door to it as a child. Set the door mass to something less than 10. Objects with a mass less than 10 can be picked up by the player, but given its attached to the hinge it should move in only the ways the hinge permits it. Like I say, total guess work but perhaps worth a try. Also, if I remember correctly, the numbers used for hinges are very finnicky, down to decimal points. Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 22, 2016 Author Share Posted September 22, 2016 I've set the Hinge.lua script to the pivot and the door is a child of the pivot. I've enabled limits as well and given the door a mass of 5. As soon as I run the game the door just falls through the floor lol. Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 22, 2016 Author Share Posted September 22, 2016 I still can't seem to figure out how the Joint class works. I'm using the Hinge.lua script and I am inputting random numbers for the Vec 3 inputs and for the limit boxes as well. Stuff is happening but I just can't seem to figure out how it works Every time I go to the object that has the Hinge.lua script attached to it and press the E button, as soon as I move my camera the object goes beserk lol. It flies off so fast that it looks like it's just suddenly vanishing haha. Here is a quick video showing what I am expecting to happen (at the start of the video) Then I show you what actually happens when I run it. https://www.dropbox.com/s/l3qafy91px4o7ct/2016-09-23_00-09-49.mp4?dl=0 Quote Link to comment Share on other sites More sharing options...
Angelwolf Posted September 23, 2016 Share Posted September 23, 2016 I've set the Hinge.lua script to the pivot and the door is a child of the pivot. I've enabled limits as well and given the door a mass of 5. As soon as I run the game the door just falls through the floor lol. Sounds like you put a mass value on the pivot, not the cube. The cube will also need a script attached to it, but nothing written in the script. An empty script, if you will. Also if you use joints and have a mass less than 10, the door will fly about because it doesnt know if you want to open a joint or pick up an object. Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 23, 2016 Author Share Posted September 23, 2016 I've gone through everything you have mentioned above and I am still having the same problem. The door is the only thing with a mass value and it's attached to the pivot (the pivot is the parent). It still falls through the floor though. Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted September 23, 2016 Author Share Posted September 23, 2016 Problem is fixed now after speaking with Roland who seems to be completely in love with the flowgraph editor haha! https://www.dropbox.com/s/4loqmity8mhfaa1/2016-09-23_21-21-54.mp4?dl=0 Later down the line I will see if I can add functionality to drag the door open rather than it opening with a button press. For now I am going to continue mapping and creating textures to get my level complete. 2 Quote Link to comment Share on other sites More sharing options...
Roland Posted September 23, 2016 Share Posted September 23, 2016 Yeah. Here is a high five for the Flow Graph Josh 2 Quote Roland Strålberg Website: https://rstralberg.com 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.