I'm making AI to tell a minion to chase and attack the player.
I played Magicka, and the minion follows the player in a nice curved manner (left image), rather than what I currently have (right image), where the minion just keeps reacting the the player's changes in X,Y.
The code I have makes the chasing minion appear to move in a blocky way as it keeps trying to have its coordinates == the player's coordinates:
if (enemy.pos.x <= game.data.playerX) {
enemy.body.vel.x += enemy.body.accel.x * me.timer.tick;
}
else {
enemy.body.vel.x += -enemy.body.accel.x * me.timer.tick;
}
if (enemy.pos.y <= game.data.playerY) {
enemy.body.vel.y += enemy.body.accel.y * me.timer.tick;
}
else {
enemy.body.vel.y += -enemy.body.accel.y * me.timer.tick;
}
How can I achieve a more smooth transition effect?