Okay, so right now, my Entities have both a position and a rotation vector. I have a follow(Player) function, but as you may have imagined, the object is facing the same direction while it’s chasing the player. Ultimately, I would like the entity to face the player as he chases him. Here’s what I have in mind:
double theta = Math.tan(dz / dx), angle = this.getRotY() + theta; //dz and dx are the sides of the triangle that I use for distance if (angle == 0) increaseRotation(0, 0, 0); else if (angle > 180) increaseRotation(0, (float) (-angle), 0); else increaseRotation(0, (float) (angle), 0);
Any ideas? Sorry if this is super simple, but I’m having a tough time thinking this through (very tired, at the moment).