Power Ups In Bb3? (invincibility, Boosts, Coin Magnet)

Discussion in 'Buildbox 3.0' started by landofgreendev, Aug 27, 2019.

  1. landofgreendev

    landofgreendev Boxer

    Joined:
    Nov 9, 2018
    Messages:
    85
    Likes Received:
    18
    Hi all,

    I was just wondering if it is possible to integrate ‘power ups’ into BB3 games? I’m not sure if power ups is the right term but I would like to add boosts, a coin magnet and invincibility. Has anyone been able to create Power Ups yet in BB3? And if so, which ones have you made?

    There must be some workarounds even if there aren’t pre-loaded nodes in BB3.

    I’m sure there must be a way, the invincibility must be pretty straight forward by just removing the ‘if collide’ node. Any help would be so much appreciated, they would be such a great addition to not just my games but anyone’s games!

    Many thanks!
     
  2. landofgreendev

    landofgreendev Boxer

    Joined:
    Nov 9, 2018
    Messages:
    85
    Likes Received:
    18
  3. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    let collide = this.entity().component('If Collide');
    if(collide && !this.entity().component('state').return_invicible()){

    }
     
    landofgreendev likes this.
  4. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    let collide = this.entity().component('If Collide');
    if(collide && !this.entity().component('state').return_invicible()){
    /// your action comes here ////
    }

    hi,
    this way you can implement that invincibilty effect.
    add a script named state do the work there and after if collide node add this script , this way it will only work when character is in a specific state , you can add another if statement and write the game to destory that collided object if character was invincible
    if(collide && this.entity().component('state').return_invicible()){
    let obj = collide.collisionObject();
    /// obj.remove() ///
    }

    something like this.

    for coin magnet add another part in the state component and for the coins add a wake up node
    and before that wake up node add a script to tell them if the coin magnet was active then the wake up works
    and when wake up was emit a signal to a script which tells coins to change their position and come towards the character


    for boosts
    for example speed up
    just tell the code to check a varibale and if it was true set the speed 10 times of the normal or sth like this

    var speed = 5;

    update()
    {
    if(this.entity().component('state').return_speedup())
    speed = 50;
    else
    speed = 5;

    }

    hope this helps
    if you had any questions or needed more help with this just leave a reply and i'll be here.








     
    landofgreendev likes this.
  5. landofgreendev

    landofgreendev Boxer

    Joined:
    Nov 9, 2018
    Messages:
    85
    Likes Received:
    18
    Can't thank you enough for this! Looking forward to trying it out. Will let you know how I get along with it!!

    I love this Buildbox community!

    Thanks again,
    Will
     
  6. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    :)
     
  7. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    @mamal Can you explain this in brief?
     
  8. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    i suck at explaining stuff in brief but i will try :D

    at first you have to add a component ( script ) to your main character
    to evaluate the states which the character has.

    state script :

    var invincible = false;

    function set_invincible(value)
    {
    invincible = value;
    }
    component.set_invincible = set_invincible;

    function return_invincible(value)
    {
    return invincible;
    }
    component.return_invincible = return_invincible;

    with something like this you can change the character state and determine which state is true or not.

    invincibility:
    let's say character collides with the invincibility star ( super mario style :)) )
    and then it goes like this : set_invincible(true);
    now let's say the character collides with the hazard , you will have to connect the if collide node to a script which goes like this:

    let collide = this.entity().component('if collide');
    if(collide && this.entity().component('state').return_invicible()){
    let obj = collide.collisionObject();
    obj.remove();
    ///// the character is invincible and when it collides with any hazard that hazard is removed and nothing happens to the character;
    }
    if(collide && !this.entity().component('state').return_invicible()){
    this.emitSignal('defeat' , true);
    /// the character is mortal and well... after this collision something bad will happen to the character;
    }

    speed up:
    changing the state and having it in return is like the past part ,um and here i'm trying to give you something that you can actually use in your game.
    let's say character collides with the speed up booster
    and then it goes like this : set_speedup(true);
    but this function is a bit different

    fucntion set_speedup(value)
    {
    if(value)
    {
    this.entity().component('move').set_speed ( 10 //forexample);
    }

    }

    ok now to finalize this , as we know these effects will wear off after some time so how to do it?

    function set_invincible(value)
    {
    invincible = value;
    if(value)
    this.emitSignal('invincible' , false);
    }

    fucntion set_speedup(value)
    {
    if(value)
    {
    this.entity().component('move').set_speed ( 10 //forexample);
    this.emitSignal('speedup' , false);
    }
    else
    {
    this.entity().component('move').set_speed ( 5 //normal speed forexample);
    }

    }

    Capture.PNG
    function signal(name , value)
    {
    if(name == 'speedoff' && !value)
    this.set_speedup(value);
    if(name == 'mortal' && !value)
    this.set_invincible(value);
    }

    and with those 2 delay nodes you will control how much the effects last.
    so this is it
    hope this helps ♥
     
  9. landofgreendev

    landofgreendev Boxer

    Joined:
    Nov 9, 2018
    Messages:
    85
    Likes Received:
    18
    That's awesome, I'll try it when I get home!

    Have you got a BBDOC? No problem if not -

    Thanks again
     
  10. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    Thank You So Much @mamal . I don't know how to code.And this is a huge help:)
    If you have BBDOC please do share with us.
    Thanks Again
     
  11. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    uh sorry guys but no bbdoc i came up with the code just here
     
  12. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    I am unable to use the code . I am not if what I am doing is correct or not. Can Someone Correct me please
     

    Attached Files:

  13. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    @landofgreendev Can you share bbdoc if you are successful with create powers through nodes
     
  14. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    why are they all in the same script ? :l
     
  15. Rusted

    Rusted Avid Boxer

    Joined:
    May 24, 2017
    Messages:
    133
    Likes Received:
    39
    Sooooo disappointing these basics in BB2 have to be scripted Inc BB3. Big let down at the moment.
     
  16. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    i don't know about you but i prefer this environment and i feel more comfortable when i can code stuff into my games.
    but still bb3 doesn't involve you with lots of codes and that's a big help.
     
  17. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    What Should I do ?Can You Please Help Me Out?
     
  18. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    um , i will prepare a bbdoc for you as soon as possible.
     
    itzonator likes this.
  19. Bhavik

    Bhavik Boxer

    Joined:
    Aug 23, 2019
    Messages:
    16
    Likes Received:
    2
    Thank You So Much Mamal
     
  20. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    204
    Likes Received:
    181
    Last edited: Sep 5, 2019

Share This Page