Jump to content

Doors ... Amnesia Style


SlipperyBrick
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 sad.png

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Upvote 2
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...