So I want my wall to act like a hinder and won’t go away unless you press a certain button. I found this script that is said to make your object go away. I have error on my code so I’m wondering how to fix it?
// Use this for initialization
void Start () {
GetComponent<Renderer>.enabled = false;
}
// Update is called once per frame
void Update () {
}
}
Thank you very much it worked! I was thinking about adding preassure so you can’t pass the object without right click away the object does it work with adding collision or do I need to code it?
I didn’t understand exactly what you mean, but when you want automatically disable your Object by hitting colliders, so you have to set an Event with OnCollisionEnter() or similar Collision functions.
Of course you have to script this. Such situations are very well discribed in the Manual and Scripting API.
I mean that the object I now thanks to you can dissapear when I press a button I want it so that my ball can’t pass it unless I press the button. Because now it can simply pass it and I don’t want that.
I have gone through the 2d UFO tutorial and then there was another one I watched I don’t remember the name but talking about colliders so that’s what I’m wondering if I should use it in my case? Though I feel like when I press Fire1 and the wall is gone and I have added say collision won’t there be an invisable wall then? I’m then thinking about instead just adding adding 2d box collider to the wall since it has a trigger option you can apply but I’m not sure or you can make a script for it?
This is why going over some more of the tutorial lessons will be a great help to you with Unity & building your game.
You would learn about colliders and triggers, for instance.
You can setup colliders (non-trigger) to prevent your ball from going through, if it’s moving with physics. That is, it’s handled for you that way. Instead of simply disabling the renderer, you could disable the game object.
Thank you I looked more into the collider function and it worked on the object to stop the ball though when I press fire1 for it to go away I still can’t pass it?
What I mean is, if you were blocked by the collider, and pressed the button to make it go away, hopefully you disabled the game object (so it can’t be seen, or stop you from passing).
If you can try doing that & write back about your success …?
Feel free to post your code, if you are stuck, too.