private static void Advance(INPC e, GameTime time) { Again: Vector3 v1 = e.Path.Current; e.Path.NextNode(); Vector3 v2 = e.Path.Current; Vector3 v = (v2 - v1); if (v.Length() == 0) { goto Again;//Duplicate, should not exist } v.Normalize(); if (v.X != 0 || v.Z != 0) { float angle = (float)Math.Atan(v.X / v.Z); if (v.X == 0 && v.Z < 0) { angle += MathHelper.Pi; } Vector3 newrot = new Vector3(0, angle, 0); if (!newrot.Equals(e.Rotation)) { e.StopWalking(time); } e.Rotation = newrot; } }
public void Register(INPC enemy) { enemies.AddFirst(enemy); enemy.Position = enemy.Path.Current; enemy.StopWalking(Manager.Game.GameTime); }
private static void Advance(INPC e, GameTime time) { Again: Vector3 v1 = e.Path.Current; e.Path.NextNode(); Vector3 v2 = e.Path.Current; Vector3 v = (v2 - v1); if (v.Length() == 0) goto Again;//Duplicate, should not exist v.Normalize(); if (v.X != 0 || v.Z != 0) { float angle = (float)Math.Atan(v.X / v.Z); if (v.X == 0 && v.Z < 0) angle += MathHelper.Pi; Vector3 newrot = new Vector3(0, angle, 0); if (!newrot.Equals(e.Rotation)) e.StopWalking(time); e.Rotation = newrot; } }