Search Unity

Script. Help please

Discussion in 'Scripting' started by matt_novoselov, Oct 23, 2018.

  1. matt_novoselov

    matt_novoselov

    Joined:
    Oct 23, 2018
    Posts:
    2
    Hi ! I am a novice developer and would like to ask for help from the experienced people. I need to write a script: if all 3 objects are in the scene (true), the other object must disappear (false) . Thank you!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Just post the script as you have written, remember to post using CODE tags so people can read it clearly, and say what the script is doing wrong that you can't figure out.

    If you just want someone else do write it for you, try Unity Connect instead.
     
    matt_novoselov and eses like this.
  3. matt_novoselov

    matt_novoselov

    Joined:
    Oct 23, 2018
    Posts:
    2
    Ok, thanks... I will try it!!!
     
  4. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I agree that you should post the code, and perhaps better describe what you are trying to accomplish. Always assume that we don't know anything that is blindingly obvious to you, and take the time to descibe even obvious stuff.

    For example, you wrote:

    "if all 3 objects are in the scene (true), the other object must disappear (false)"

    Some silly people like me would read this and say: "hey, wait a minute, how can there be *another* object when we already have *all* three objects in the Scene?"

    Are there four objects, or will one of the three disappear when the other two are present? In the latter case, you could run into an ugly oscillation, because when you make that object disappear, and it is part of the three you use to determine if all are present, is is no longer there.

    So, perhaps describe *all* objects that are relevant for this problem, and describe why they are relevant and how they interact. For example, describe (or show the code) how you know if an object is in the scene. If that is part of your question (how do I determine if an object is in the scene), also ask that question. Make sure you remove all doubt in meaning: some people may interpret what you say differently. For example, some may interpret the 'in the scene' bit to mean 'visible to the player', which can be a far cry from an object that is in the scene, but invisible to the player (because it is behind them). And what does 'disappear' mean? Remove it from the scene (Destroy), keep it in the Scene but remove from the game Loop (inactive), or Keep it active, but remove all visual representation (e.g. disable the mesh renderer)? These may be obvious to you, but it's not obvious to us.

    I often find that when I take the time to describe my question in great detail here, I find possible answers myself.

    Cheers,
    -ch
     
    Last edited: Oct 25, 2018