How Can I Get Variables From Components On Other Objects?

Discussion in 'How Can I...?' started by Nathan Meier, Jan 8, 2019.

  1. Nathan Meier

    Nathan Meier Boxer

    Joined:
    Dec 24, 2018
    Messages:
    12
    Likes Received:
    0
    I'm trying to figure out how to grab data like variables from components on other objects. I've been using component reference in my code but when I try to get a variable it comes out NaN. Does anybody maybe know why? Here's the code I'm using so far:


    function signal(name, value){
    if(value == true){
    let collision = this.entity().component('If Collide - Pillar');
    let collObject = collision.collisionObject();

    let pillar = collObject.component('Pillar Life');
    let jump = this.entity().component('Jump');

    if(pillar._life > 1){
    collObject._life -= 1;

    collObject.setPosition(collObject.position().x,
    collObject.position().y - 1,
    collObject.position().z);

    } else {
    jump._stop = true;
    pillar._life -= 1;
    collObject.setPosition(collObject.position().x,
    collObject.position().y - 1,
    collObject.position().z);
    this.emitSignal('Jump', true);
    }

    }

    }

    if anybody has any ideas that would be most helpful.
     
  2. Tom King

    Tom King Boxer

    Joined:
    Nov 23, 2018
    Messages:
    24
    Likes Received:
    15
  3. Nathan Meier

    Nathan Meier Boxer

    Joined:
    Dec 24, 2018
    Messages:
    12
    Likes Received:
    0
    I tried downloading and opening the asset file, but BuildBox tells me it's an Unrecognizable format. Do I need to update BuildBox 3 maybe?
     
  4. Tom King

    Tom King Boxer

    Joined:
    Nov 23, 2018
    Messages:
    24
    Likes Received:
    15
    Did you drag it into the interface? You can't open asset files, only .bbdocs
     

Share This Page