door opening

i have searched for this a lot but i can’t find it.
i am searching for a script where you can play an animation of a door opening then staying open and when pressing e on it again it closes(maybe some fancy sound).
it would be helpfull for a lot of people.
also, how would you do that in cinema 4d?
what i have now is frame 1 to 50 opening animation 51 to 100 closing animation.
do i need to put an idle animation in it?

thanks for every one who would like to help.

You don’t need the closing animation, unless it’s different, you can play the opening backward. But you need to know the current state (openned, closed, moving)

You don’t need to use any frame animation at all.
You can easily script the animatior instead.

If these are sliding doors you can use position

function Update() {
transform.position = Vector3(Mathf.SmoothStep(minimum, maximum, Time.time), 0, 0);

If hinged

just use transform.eulerAngles.y

using UnityEngine;
using System.Collections;

public class door: MonoBehaviour {
private int lastindex;
public void play()

// Use this for initialization
void Start () {


// Update is called once per frame
void Update () {



this is for playing the right animation.