What I have is a character in the middle of the screen and enemies behind him. What I want to do is, make the enemies gravitate towards the character. Any idea how can I do this?
in Nite Fighter i did this with 2 variables per enemy. UD for up and down LR for left and right. then after conditioning the position of the main character in relation to the enemy you can use those variables to make the enemy move towards the character. in the update function of the enemy my code was something like this.... (writing from scratch probably have errors in it) let enemypos = this.entity().worldPosition(); let character = this.scene().find('Actor')[0]; let characterpos = character.worldPosition(); // then to check the x axis i wrote something like this (do the same with UD for the y axis)// if (enemypos.x >= characterpos.x){ LR -= 0.1 }else{ LR +=0.1 } // then i add the LR variable to the current position of the enemy to make it move towards the character // this.entity().setPosition(enemypos.x+LR,enemypos.y+UD,enemypos.z); essentially you're constantly updating two variables to 'swing' towards the character. good luck