Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

107 Neutral

About forgetful_user

  • Rank
  1. forgetful_user

    Disable Colliders

    Here's the result, still won't interact with the Box Collider. public class DisableCollider : MonoBehaviour { Collider boxCollider; public bool Open; void Start() { boxCollider = GetComponent<Collider>(); } void Update (){ if (Open == true) { if(Input.GetKeyDown(KeyCode.E)) { boxCollider.enabled = !boxCollider.enabled; Open = false; } } else if (Open == false) { if(Input.GetKeyDown(KeyCode.E)) { boxCollider.enabled = !boxCollider.enabled; Open = true; } } } }
  2. forgetful_user

    Disable Colliders

    Thank you very much, it got the Open to change states, but not the Box Collider. Also, it seems to very inconsistent.
  3. forgetful_user

    Disable Colliders

    x was only temp, but thank you very much, and yes it is. It is on a wall in a house, and I want the player to be able to walk to the wall and press E so that they can walk through it.
  4. forgetful_user

    Disable Colliders

    Do you mean something like this? public class DisableCollider : MonoBehaviour { public bool x; void Update (){ if (x == true) { if (Input.GetKey (KeyCode.E)) { GetComponent<Collider> ().enabled = false; x = false; } } if (x == false) { if (Input.GetKey (KeyCode.E)) { GetComponent<Collider> ().enabled = true; x = true; } } } } I tested it out, and not working for me. It won't change the state of the collider or x.
  5. forgetful_user

    Disable Colliders

    Hey, so I'm new to game developing and I have essentially no coding experience aside from a few YouTube tutorials. I'm trying to make something that when the play clicks a button, it'll deactivate the collider a allow the player to walk through it.   using UnityEngine; using System.Collections;   public class DisableCollider : MonoBehaviour      {           public int x;           void Update (){                if (x == 0) {                if (Input.GetKey (KeyCode.E)) {                     GetComponent<Collider> ().enabled = false;                     x = 1;                }           }      } }   I also wanted to press the same button to reactivate the collider as well. Any help?  
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!