Spawn An Object From A World To Another

Discussion in 'How Can I...?' started by LtgGames, Jun 11, 2020.

  1. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    Hi boxers! I´m (unfortunately o_O ) making a kind of complicated RPG-game. Is it possible to spawn an object that will be activated in one world, and than it spawns up in the next world? Let me clarify: If the character collects a key in world one - can I make a secret chest emerge in world 2? I have already tried send-recieve-spawn, but so far it only works inside the respective world.
     
  2. spicedbeangames

    spicedbeangames Miniboss Boxer

    Joined:
    Mar 31, 2016
    Messages:
    1,389
    Likes Received:
    596
    Have you tried using true/false with the triggers? You might also need to use the save variables in the new world to store that true data. Its not something I have done, but try asking in the discord channel. Lots more help there
     
  3. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Yes you can do it .u need to do little coding for that and that is very easy.
    All you have to do is when you collect a key. You need to store a variable with data in setting class and then make a condition which checks if you have a variable in setting class then you can enable the chest in world 2
     
  4. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    oh... First: Where is setting class? Second: What data to put in there?
     
  5. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    I have the same issue. @Elite Games, can you post a code example please?
     
  6. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Ok i will create logic for you guys.
     
    Jaro and LtgGames like this.
  7. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Check api documentation for setting class.

    https://www.buildbox.com/help/buildbox-3-api-reference/settings/

    2nd lets for example you can store a bool variable to true in setting class then check if settings contain that variable and its true then trigger your custom function. I will create a simple node for you dont worry. You can store many types of data in setting class
     
    LtgGames likes this.
  8. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Hi Everyone Download Keys System from Below.

    https://rb.gy/rhbkin

    You can create and store unlimited Unique Keys.

    Watch the tutorial Video Included.

    Logic Detail :

    If you Collide with Key object it will going to store a key With Key Name and key value in Setting Class and key object will get remove.
    Key Checker object have Key check Script Attach. It will Check for Same Key Name and value which were saved previously. If we have collected the same key which is defined in the script then object will become visible. else it wont be visible.
    Also there is Remove Key Script Attach in case you want to delete the key from setting Class. Just Enter Same Key Name and tick Remove Key option.

    Thanks
     
    LtgGames likes this.
  9. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    You almost literally saved my day! Thanks! Your script works perfectly!
     
    Elite Games likes this.
  10. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    Thank you for this. I think this is how the Buildbox folks intended the “save variable” and “load variable” to work. They should drop there versions of the nodes and use yours (slightly modified) in the product.
     
    Elite Games likes this.
  11. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    I think we should have assetstore for custom bb nodes. So we can download and try custom bb nodes within the software. Also If they can bring intellisense in the code editor that will be a great help for creating custom nodes.
     
  12. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    There seems to be an issue with the functionality of the nodes. When my character is defeated in a level, somehow it is triggering an additional key. I checked the names and values, and they are all correct. Any thoughts?
     
  13. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Can you share your bbdoc. Actually u need to connect script with object not character if character collide with lets say key it will then store key. on the other hand u need to check for a key. Depends upon your game u may need to create a different logic. U can send me your bbdoc and i will look for the issue
     
  14. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    I believe found what I did wrong. It wasn’t with your code. I had a “variable save” and “variable load” nodes still in the node map. I removed them and it now seems to be working. Thank you again for your great work!
     
    Elite Games likes this.
  15. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    @Elite Games I tried to modify your key system to trigger a position animation node witch I connected to the "Check Key" node. It works the first time, but does not persist. I did this to create a level selection that is more interactive then just pressing a button on a UI. If I can get it working, I believe it will be pretty cool. Anyway, I am going to put the code below and would appreciate if you could figure out why the animation doesn't happen each time the user enters the level selection world (not just the first time). If the key is stored in settings, then when the "check for key" script occurs, it is supposed to trigger the animation but for some reason only does it immediately after the corresponding key is saved. Here is the code:
    For Key storage:
    _____________________________________________________________________
    var keyName;
    var KeyValue;

    function init(){
    keyName=this.attribute("Key Name");
    KeyValue=this.attribute("Key Value");
    if (Settings.Keys == undefined) {
    Settings.Keys = new Object();
    }
    }

    function start(){
    }

    function update(dt){
    }

    function signal(name, value, sender){
    if(name=="in"&& value)

    {
    Settings.Keys.keyName=KeyValue;
    warning("You Stored a Key Object with Name "+ keyName + " and key value is " +Settings.Keys.keyName);
    this.emitSignal("out",true);
    }
    }

    function requested(name, arg, sender){
    return this;
    }

    For the check key:
    _____________________________________________
    var keyName;
    var KeyValue;
    var CheckKey=false;

    function init(){
    warning("This Script Check If You have a key stored in setting class. If there is a Key then this object will become visible else wont be visible");
    if (Settings.Keys == undefined) {
    Settings.Keys = new Object();
    }

    keyName=this.attribute("Key Name");
    KeyValue=this.attribute("Key Value");
    }

    function start(){
    //hide this object if we dont have a key
    this.emitSignal("out",false);
    }

    function update(dt){
    if(CheckKey)
    {

    //check if we have a key stored in setting class
    if(Settings.Keys.keyName!=null && Settings.Keys.keyName==KeyValue )
    {

    // show this object if we have a key
    this.emitSignal("out",true);
    }

    else {
    //hide this object if we dont have a key
    this.emitSignal("out",false);
    }
    }
    }

    function signal(name, value, sender){
    if(name=="in"&& value)
    {
    CheckKey=true;
    }
    }

    function requested(name, arg, sender){
    return this;
    }
     
  16. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Can you show me a video what you want or send me your bbdoc and i will look into it for you. check if you are not removing key from setting. If we remove key then false signal will get trigger.
     
  17. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
  18. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Max Huchthausen likes this.
  19. Max Huchthausen

    Max Huchthausen Boxer

    Joined:
    Oct 30, 2018
    Messages:
    26
    Likes Received:
    3
    Thank you for your work. Can't wait!
     
  20. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    I will release a temporary solution to your problem. I need some time to work on this also i am busy in couple of other projects that are nearly available for release.
    I will send you dm soon. Sorry for the delaying issue.

    The current problem with key system is i thought that we dynamically creatw new keys in settings class. But here we are just replacing key value so when we save other keys they get replaced. I am shifting this to array for current situation but i am having small issue with that and that need to be fixed before release
     
    Max Huchthausen likes this.

Share This Page