- Home /
Too subjective and argumentative
Draggable Doors Like Amnesia?
What would be the best way to go about creating click-and-drag doors like the ones in Amnesia (which actually function the same)? This means they would behave realistically with continued movement after mouse release, and damping that slows them down appropriately.
I have been trying to put together this feature for over 2 months now, and nothing works. I have read ALL the questions and answers and forum posts on this topic, and have tried Configurable Joints as well as different scripts (such as DragRigidbodyShadow and others I've found on the forums). However, these Configurable Joints in my experience have been very buggy and unpredictable, and seem to do whatever they want regardless of how you set them up.
Well, asking here is my last resort, as I simply cannot figure out a way to pull this off. What I'm looking for is an example to go by, because not only am I terrible with interpreting explanations without examples, I've also exhausted all my ideas.
I do have a script I've been trying to write for this, which I've customized to let me clamp the pitch and volume of a repeating door creaking loop based on a float value of the current speed at which the door is turning. I also have functions which trigger the opening and closing sounds. However, I've decided at this point that I need to go about achieving this draggable door feature a completely different way (again). So, instead of trying to work from the unsatisfactory progress I've made so far, I think it would be best if I just started with a clean slate, implementing them in whatever way would work best.
TL;DR: I'm looking for a way to achieve draggable doors like those in Amnesia, meaning they:
Must be clicked on and "dragged" to open, either with the mouse or by stepping backward, as long as the player is still holding down the mouse button.
Respond appropriately to the set limits, and don't glitch around if opened too quickly.
Stick to the "minimum" limit (closed position) once it's reached, and must be clicked and dragged again to re-open.
Can someone please help me out with this? It's been quite a while since I started trying to achieve this, and since then I've gotten absolutely nowhere.
EDIT: Cleaned up and re-worded
im guessign here as i've never done it, but i would try a hinge at a point of the door as required, and then use the drag script from community scripts site
I have a mechanic which is honestly working better than Amnesia door mechanic. I also implemented a drag object mechanic. I'd say keep messing with rigidbody and joint mechanics to have something to your taste.
I have kept messing with them, that's why I'm finally just turning here for help. Nothing I've tried has worked.
Something like this?: http://www.youtube.com/watch?v=gfRu7olj79E
Yes! The door behaviors in that video are actually exactly what I'm ai$$anonymous$$g for. It doesn't matter what I do, though, it's always just a glitchy mess. It's really annoying how most things that are so simple and have been done so many times before always just end up being oddly impossible for me to achieve. :/
Answer by KMKxJOEY1 · Aug 21, 2014 at 12:56 AM
here is a snippet from something relatively similar:
else if (activeTool == Tool.Rotate && mouseDown)
{
float deltaX = (mouseStart.x - Input.mousePosition.x) / 3f;
activeEditObject.transform.eulerAngles = new Vector3(activeEditObject.transform.eulerAngles.x, deltaX + startRot, activeEditObject.transform.eulerAngles.z);
}
Plug and chug buddy; basically when MouseDown event is called save the mouseStart vector to a variable, then rotate it based on the current mouse position until the MouseUp event is invoked. Be sure to check that the mouse is over the door when you check the MouseDown event :)
Ofc you need the transform root to be the hinge in order for the door to rotate properly.
Happy coding.
This answer sounds reasonable. About the original question: I don't like the lack of formatting, specifically the lack of any paragraphs, that everything is in one big, hard-to-read text block, and that half of the sentences sound like rants about a perceived lack of tutorials for this feature.
Thank you. It's been a little while, but as soon as I'm able to I'll try this.