Search Unity

Can anyone help me with door animation?

Discussion in 'Getting Started' started by charleedmunds, Nov 28, 2018.

  1. charleedmunds

    charleedmunds

    Joined:
    Nov 28, 2018
    Posts:
    3
    could anyone help me with c# coding for unity? i need to get my doors to automatically open and shut when my character goes towards and away from the door. i found some code online and it isnt working. i am only new c# so any links to where i could gain this information or advice or an example code block would be very useful. thank you
     
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
  3. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
  4. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Unity has an animation system that lets you setup in game so you can close the door then record the position and open the door and record the new position and adjust the animation to move the door between the two.

    Then all you need is a trigger volume that will run the animation when the player moves near the door or trigger code that will be activated by a in game switch.

    I used this for a remake of doom level 1, includes the trigger code and animations.


    Playable demo and project files - https://arowx.itch.io/doom-retro-remake-level-1