【发布时间】:2015-10-10 19:34:27
【问题描述】:
我正在开发一款 2D 游戏。我试图弄清楚如何确定一个 Vector2 是否面向另一个。
这是我目前所拥有的:
public void update(GameTime gameTime, Vector2 playerPosition)
{
// position is "enemy" Vector2
// rotationAngle is the angle which the "enemy" is facing
// I need to determine if the "enemy" should rotate left, right, or move forward
// The goal is to have the "enemy" move towards the player
float angle = MathHelper.ToDegrees((float)Math.Atan2(playerPosition.Y - position.Y, playerPosition.X - position.X));
float rotationDegrees = MathHelper.ToDegrees(rotationAngle);
// Now what????
update(gameTime);
}
【问题讨论】: