Search Unity

Raycast open door & close after cross door

Discussion in 'Scripting' started by Santander507, Mar 15, 2019.

  1. Santander507

    Santander507

    Joined:
    Aug 30, 2018
    Posts:
    1
    Could you help me? I'm new to scripting. It would be a great favor. I want to make the door open with a raycast by pressing the "e" key and then when you cross the door, it closes automatically without pressing any key.

    I think that for the door to close automatically when you cross it, we use box collider, right?
     
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Santander507,

    Unfortunately, your question is too vague to get you any meaningful responses. To begin with, you may want to mention whether this is a 2D or 3D project you are working on.

    There are so many ways to approach this high level goal, it's difficult to know where to start. Personally, I would recommend beginning with some simple projects to find your feet a little. However, if you must continue with this one, you can read about handling user control input here and raycasting here.

    I would also recommend following some of the many excellent Unity tutorials that can be found by pressing "Learn" at the top of this page. :)