Node Script Push Button To Move An Object In Scene

Discussion in 'Buildbox 3.0' started by flyyf, Aug 23, 2018.

  1. flyyf

    flyyf Boxer

    May 12, 2016
    Likes Received:
    Hi Boxers,

    Today question: I try this afternoon have a button trigger and when actor touch it, an object move X axis (as the example door in asset). I want understand how do it myself this.

    My logic :

    a) I created a node if collide in actor with in affected asset The PushButton
    b) I Connect a Move node to the if collide, and open it and try to change the defaut java script (it´s my first time with JS...) to find identity and put new value X to MoveObject when actor shock the push button. But, of course, the code is wrong and I don´t know if it´s better put it directly to the MoveObject (example in a node "open animation") and we can call it when Actor Shock the push button [with my "if collide" I explain in point a) ]

    - 1 hour after, new code update from defaut JS example with key in asset, it´s working little bit but if someone can tell more...)
    var _enabled = false;
    var _rot;
    var _counter = 0;
    var _id = 0;
    function init(){
    _rot = this.entity().position();
    _id = this.attribute('Identification');

    function update(dt){

    if(_counter < 1){
    let anim = easeInOutCubic(_counter);
    this.entity().setPosition(_rot.x*(1-anim), 0, 0);
    _counter += dt*1.5;

    function signal(name, value){
    if(name == 'Open' && _id === value){
    _enabled = true;

    function easeInOutCubic(t){ // return from 0 to 1 easyInOut value
    t /= 1/2;
    if (t < 1) return 1/2*t*t;
    return -1/2 * (t*(t-2) - 1);

    big thanks.
    Last edited: Aug 23, 2018

Share This Page