- Home /
How to make a door like the ones in Amnesia: The Dark Descent
I am making a first person game that takes place mainly in hallways and buildings, and as such, I need to have doors. I want to make the doors like the the ones in Amnesia: The Dark Descent, by which I mean that if you click and hold down the left mouse button on a door, then the door opens away from you slowly as you slide the mouse forwards, and the opposite happens if you slide the mouse backwards. I am not very experienced (and just plain bad) at scripting, so is there a script that I could use? Any suggestions would be appreciated greatly.
Don't say you're bad at scripting. It's negative thinking and only serves to make you think you can't do things that you can, with practice.
Answer by Wibbs 1 · Apr 09, 2011 at 11:26 PM
There isn't a certain script you can use I'm afraid. The only thing I can suggest is that you try breaking what you want to do down into smaller and smaller steps, and work out how to acheive each one in turn. For example, you may decide to break it down as follows:
- Import the model of the door (and wall?) from your choice of 3d modelling package into Unity
- Detect when the player presses the left mouse button down
- Work out whether the mouse pointer is over the door handle when it is pressed
- Track the change in vertical position of the pointer while the button is down
- Move/animate the door based on how far the mouse has moved
These are all extremely simple steps though, coding wise. All but step one can be done in a single line of code each.
very nice answer, i suggest the detection with trigger and the trigger box, then the mouse recognition this way, the player object needs to be on range of the door, then make the interaction with the mouse, thumbed you up
Your answer
Follow this Question
Related Questions
transform.RotateAround problems 2 Answers
Trouble with java raycast scripts to open a door 0 Answers
Cube changes size when adding HingeJoint 2 Answers
door script problems 2 Answers
Trouble with Animation 0 Answers