Bb3 Character Setposition()

Discussion in 'Buildbox 3.0' started by AaroArts, Sep 3, 2019.

  1. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    Hello.
    How do you set the Characters position relative to the scene it’s in?

    Whenever I try to setPosition(x,y,z), it’s either moving it based off it’s origin or the world coordinates.
    I’m just trying to set it’s position based on the object it lands on in that scene.

    Any help would be appreciated.
    Thanks.
     
  2. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    If I understand you right could you mot get the position of the object you collide with and use that to set the characters position?
     
  3. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    Yeh that’s what I’m thinking, but how is that achieved?
    It’s very hard without any documentation.
    Thanks.
     
  4. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    Here this code will get you the object you collided from. Just hook up an "If Collide" node in you r character to a script with this in it

    Code:
        let collideNode = this.entity().component('If Collide');
        let collisionObj = collideNode.collisionObject();
        log(JSON.stringify(collisionObj.position()));
    
     
    AaroArts likes this.
  5. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    Thank you for posting.
    I’m just struggling at resetting the Characters position using the values.

    It seems to move the character out of the scene or something weird.
     
  6. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    Are you able to PM me your BBDOC?
     
    AaroArts likes this.
  7. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    Just bumping this thread.
    Can anyone help me with this?
     
  8. Scriv

    Scriv Boxer

    Joined:
    Oct 28, 2018
    Messages:
    50
    Likes Received:
    22
    Dig into the 'Sticky Sphere' Asset within the Asset Library... everything you need is in that asset.
    It references the collision object and then recreates it as a child of the original object... cool. Good luck. B
     

Share This Page