- Home /
How do I make a wall disappear when an objective is complete,How do I make a wall disappear when an objective is complete (ex. Player completes objective KillallEnemies, wall disappears)
Im making an FPS game but don't know how to make a wall disappear when the boss is killed, I don't even know what code to use to make it disappear,So I'm trying to make a First person shooter game that has a wall disappear like as if it were a door when the boss is defeated, but I don't know how to make it disappear when the objective is complete. In fact idk how to even make it disappear.
gameobjects have a method called SetActive so you can disable it
Answer by DoubleDotDee · Aug 05, 2020 at 12:14 PM
Just have a reference from the player to the wall:
//in the player's script
public GameObject wallToDestroy;
private bool hasKilledAllEnemies;
void Update() { if (hasKilledAllEnemies == true) { wallToDestroy.Destroy(); {
}
//in the wall's script
public void Destroy() { Destroy(gameObject); }
There might be some errors in this example but you get the idea. Trigger a function in the wall script from the player script. If there's nothing you need from the player script then just check if the objective is completed in the wall script and destroy the object. I'm not sure if this answers your question since i don't know how you detect if the objective is completed but i hope this helps.
Edit: the enters and spaces don't seem ro work (for me at least) i hope you can read it
cs(1,19): error CS0116: A namespace cannot directly contain members such as fields or methods
cs(3,14): error CS0116: A namespace cannot directly contain members such as fields or methods
cs(5,6): error CS0116: A namespace cannot directly contain members such as fields or methods
cs(1,8): error CS0246: The type or namespace name 'GameObject' could not be found (are you missing a using directive or an assembly reference?)
Your answer
Follow this Question
Related Questions
transform.RotateAround problems 2 Answers
Trouble with java raycast scripts to open a door 0 Answers
Door Script Help! 0 Answers
Best Practice for animating identical doors? 2 Answers
How to code a one way door 1 Answer