Search Unity

How to temporarily disable collisions

Discussion in 'World Building' started by rKeeling75, Sep 26, 2018.

  1. rKeeling75

    rKeeling75

    Joined:
    Sep 14, 2018
    Posts:
    3
    This has been puzzling me for a while.

    I am working on remaking some old games as a way to learn Unity. My plan is to build some clones of some simpler games and then add my own twist to them.

    One example is the old game Adventure ( https://en.wikipedia.org/wiki/Adventure_(Atari_2600) ) . My twist is that I am not using sprites but 3D objects and controlling the camera's perspective (plus a few others that aren't important).

    So far, so good... except.

    I haven't figured out how to make the bridge work. The bridge is a device that allows the player to pass 'through' walls while the player walks on it. It can be picked up and moved to other locations.

    My first thought was to make it have a vertical component that the player walks up (and then over and then down). But I am curious if there is a better way that I am not aware of in Unity.

    Any suggestions?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Funny, I was just thinking about this the other day, though I was thinking 2D rather than 3D.

    But no matter — you could handle it the same in either case. I would try a trigger on the interior of the bridge; when the player enters this trigger, you disable the collider on the player, and when they exit, you re-enable that collider.

    Of course this assumes that you're not moving the player around with physics. If you are... don't. That is the way of pain. :)
     
    rKeeling75 likes this.
  3. rKeeling75

    rKeeling75

    Joined:
    Sep 14, 2018
    Posts:
    3
    That's pretty slick. I will have to give it a try. Thanks.

    I started with 2d but for some of the 'twists' I have planned for later in the work I will need 3d. And I learned the hard way that physics caused all kinds of headaches lol. So no, no rigid bodies here.
     
    JoeStrout likes this.
  4. rKeeling75

    rKeeling75

    Joined:
    Sep 14, 2018
    Posts:
    3
    Unfortunately, I fear I am missing something. I can verify that the collider is getting disabled as I enter the bridge but walls are still 'solid'.

    I am using a Character Controller so I suspect that the collider on that is causing my problems (sneaking physics still coming into play).


    Update: Physics causes the problem but it also provides the solution: Ignore Layer Collision.
     
    Last edited: Sep 27, 2018
    JoeStrout likes this.