How to make a object move step by step

hi noob here
I want to make my cylinder move step by step to the object on a board that i create,
I have this code :
a : the start
index : the objectf

attachEvent(_this, index,a) {
  
  if(index>=a){

    _this.domEvents.addEventListener(_this.cases[index], 'click', function(event) {
    for ( var i = a; i <= index; i++) {
      _this.stepByStep(_this,i)
    }
       
 }, false)
 
 }else{

    _this.domEvents.addEventListener(_this.cases[index], 'click', function(event) {
    

     
}, false)


  }
  
}

stepByStep(_this,i)
{
  _this.tween = new TWEEN.Tween(this.pions.position)
            .to({
            x:  _this.cases[i].position.x,
            y: _this.cases[i].position.y,
            z: 5},1000)
            .start();
}

but it don’t he go to case[index] whitout step by the other case

This code isn’t self-contained (we can’t run it to reproduce your problem), and I’m assuming it doesn’t work but you haven’t mentioned any error messages etc. Since three.js doesn’t seem to be a very major part of that code snippet, asking on Stack Overflow with a larger snippet or demo, and including the Tween JS tag, might be more likely to help you get an answer.

2 Likes