How can I make "behaviors"?

Hy all!
How can I exactly make the following:
-I push a button, what slowly slides into the wall, and some kind of door is opens.

I don’t ask more, since I think if I would know this, I would know to make more “behaviors”, scripts, or what.
Thanks for helping.

Something like that, you can take a look at finite state machines. But i am thinking it should be too hard. Something like a close/open door state and when in a open door state just slowly open door/slide wall.

I know that. The question is not that.
What should I write, and how should I write the script (in C#), etc.

Ok here is a simple idea to get you started.

Put a collider on your button object.

add a script that does something like this:

public GameObject myDoor;
public bool open = false;

void OnMouseUp() // Called when the player clicks and released on the button
{
  if( !open ) StartCoroutine( "OpenDoor" );
  else StartCoroutine( "CloseDoor" );
}

opening your door could be something like this

The code abobe should give you some ideas, also it may be worth creating the door and button effect as an animation.
I did this with a small turn style door and it worked really well. Create the animation of the door opening. Then just play the animation backwards to close the door. :slight_smile: