How Can I Make Assets Show/hide When A Scene 'starts'

Discussion in 'How Can I...?' started by MarcG, Jun 12, 2020.

  1. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    I have a scene that will appear multiple times. Is there a way to show/hide assets when the scene starts?

    So the first time it gets to the scene assets A, B and C are visible and D, E and F are not.

    The second time it shows A, B and C are invisible and D, E and F are visible.

    I'd rather avoid copying the scene and having ABC in one and DEF in the other (it's impractical based on the objects, how much I think I'm going to have to tweak this to get right.)
     
    LtgGames likes this.
  2. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
    yeah,
    using these lines
    Code:
    if(Settings.levelID == "scene name"){}
    and inside assets use this
    Code:
    this.entity.setVisiblity(false or true)
    you can use trigger = 0
    when specific scene appears then trigger++
    and inside assets
    when trigger == 3 or any number then ....this.entity.setVisiblity(false or true)
     
    MarcG likes this.
  3. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    Thanks, that makes sense.

    But, stupid question, where do I put that code?!

    Sorry!
     
  4. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
    ahh, this question means that you can't do it with your own
    I will do it
     
  5. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    I understand the code and concept of what you've said.

    I just have no idea where code goes in Buildbox yet. Is there some main game loop somewhere?

    Anyway, an example would be great and will help with other things where I need some additional logic. Thanks.
     
  6. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
  7. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    I can't open the bbdoc, it says it's been created with a newer version of BB, but I'm running the latest version 3.2.2

    Are there more than 5 scenes in it, maybe it's because I'm on the free version, although can still do more than 5 scenes at the moment.

    Still need to prove a few more things before I can commit to a paid version...
     
  8. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
    mmm, no, not the number of scenes,
    I'm not using the official version, it's closed to demo version,
    anyway, I will send the script here, give me 1 sec
     
  9. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
    inside the object you want to hide add script node and add these lines

    Code:
    let names;
    function init(){
    
    }
    
    function start(){
    names = this.scene().currentLevelName();
    if(names == 'Name of the scene'){
    Settings.variable++;
    if(Settings.variable == Number){
    this.entity().remove();
        Settings.variable = 0;
            }
        }
    }
    
    change "Name of the scene" to scene name
    Number to times the scene will appear, after that the object will remove

    and inside character nodes editor add this line inside any start function
    Code:
    Settings.variable = 0;
     
    aminee likes this.
  10. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    So you put this code inside a script-node in the assets node-map?
     
  11. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    315
    Likes Received:
    158
    yup
     

Share This Page