I want to know how to make basic AI that will move around until the player gets in range and then it moves around and shoots. How do I go about that?
start easy with a rotation
var position = this.entity.getPosition().x;
this.position = this.entity.getPosition().x;
this.position = this.entity.getPosition().z;
if (((position <= this.X) && (this.Velocity < 0)) ||
((position >= this.Y) && (this.Velocity > 0))) {
this.Velocity = -this.Velocity;
}
this.entity.translate(this.Velocity * dt, 0, 0);
This is from my game the enemy rotates back and forth from there you can rotatye him other ways you will need this too
Enemy.attributes.add('X', {
type: 'number',
default: -1
});
Enemy.attributes.add('Y', {
type:'number',
default: 1
});
Enemy.attributes.add('Z', {
type: 'number',
default: 1
});
Enemy.attributes.add('Velocity', {
type:'number',
default: 1
});