You can try this.
my question is that. Is it part of architecture of unity or a bug?
gameobject.SetActive(true); work only when the gameobject is active at start of game.
void Start () {
gameObject.SetActive (false);
}
public void GameEnded(){
gameObject.SetActive (true); // runs only if gameobject is active in Inspector
}
1 Answer
1
Mavina is correct here. The problem stems from the fact that, when an object is inactive, the script to reactivate it is also inactive. Therefore it can’t call itself to make itself active again etc. The best way to do it would be to attach something like this on your end-game object(s):
public GameObject yourItem;
//On the item(s) that end the game/scene
yourItem.SetActive(true);
I don't know how it happens, but they are both looking from the same place, and when the first player moves the camera, the second player's view moves with it.
– SheepersOkay, but you didn't post the camera control script yet, and how your multiple possible players are organized.
– ChernoShould I include the whole player script in the question?
– SheepersThe way I see it is that you need to provide a) the question or problem at hand and b) all neccessary(!) information related to it. No one is helped with 10 pages of pasted script if you could instead just post the important parts and give a general outline of your player and caemra setup. Most importantly: What should happen, and what does happen?
– ChernoOk, I have tried to clarify the question.
– Sheepers