I’m trying to activate a Game Object, and when I set it to true, it is not working for some unknown reason.
Here is the part of the code:
private void ActivatePowerUpPlane()
if (score % PowerUpManager.getSecondsToWaitUntilPowerUpActivates() == 0)
This is not the whole script, but the problem accrues in when I am trying to activate the plane game object.
btw this script is always turned on, the Debug.Log() gets called and the third function gets called as well.
If the log is being called there’s only 3 possible reasons for this:
- The object referenced by planeContainer is not the right object or not enough e.g. you also need to activate a child or parent object
- There is another piece of the code, maybe in another script, that is deactivating the plane again. A simple way to detect this is by adding a script to the planecontainer and filling in OnEnable() and OnDisable(), then putting logging messages inside those to see where it’s being activated/deactivated from.
- There’s a goblin in your pc messing with your RAM
Here’s hoping it’s one of the first 2 options, because the third is quite a hassle to fix
Are you sure that the gameobject you try to activate is not a child of another gameobject which is deactivated? The activate state is inherited from the parent. Try printing
Debug.Log("planeContainer: activeSelf = " + planeContainer.SetActiveactiveSelf + " activeInHierarchy = " + planeContainer.activeInHierarchy, gameObject);
before and after you call SetActive. With SetActive you only control the activeSelf state, not if the object is actually activated. See SetActive
If that’s not the issue you should be more specific what you mean by
is not working for some unknown reason