private void MoveTo(WorldLocation direction) { var speed = _rabbit.currentVelocity; var vector = direction - _rabbit.Location; var distance = direction.Distance(_rabbit.Location); var coeff = speed / distance; vector = (vector / coeff); _rabbit.Speed.X = vector.X; _rabbit.Speed.Y = vector.Y; _rabbit.Speed.Z = vector.Z; }
private void MoveTo(WorldLocation direction) { var speed = _rabbit.currentVelocity; var vector = direction - _rabbit.Location; var distance = direction.Distance(_rabbit.Location); var coeff = speed / distance; vector = (vector * coeff); if (vector.Length > speed) { vector = vector * (float)(vector.Length / coeff); } _rabbit.Speed.X = vector.X; _rabbit.Speed.Y = vector.Y; _rabbit.Speed.Z = vector.Z; // Console.WriteLine(_rabbit.Speed.X + " " + _rabbit.Speed.Y + " " + _rabbit.Speed.Z); }