Example #1
0
 public void MoveTowardsByAngle()
 {
     Assert.AreEqual(Vector2Util.FromDeg(45f), Vector2Util.MoveTowardsByAngle(new Vector2(0f, 0f), new Vector2(-1f, 0.1f), 45f));
     Assert.AreEqual(Vector2Util.FromDeg(90f), Vector2Util.MoveTowardsByAngle(new Vector2(0f, 0f), new Vector2(-1f, 0.1f), 90f));
     Assert.AreEqual(Vector2Util.FromDeg(-45f), Vector2Util.MoveTowardsByAngle(new Vector2(0f, 0f), new Vector2(-1f, -0.1f), 45f));
     Assert.AreEqual(Vector2Util.FromDeg(-90f), Vector2Util.MoveTowardsByAngle(new Vector2(0f, 0f), new Vector2(-1f, -0.1f), 90f));
 }
Example #2
0
        public static Quaternion LookAtAngle(Chara self, Vector3 position, float maxDelta)
        {
            Vector2 vec         = self.data.rotation * Vector3.forward;
            Vector2 toTargetVec = position - self.data.position;
            var     angleSpeed  = maxDelta * Stage.Current.time.dt;
            Vector2 vec2        = Vector2Util.MoveTowardsByAngle(vec, toTargetVec, angleSpeed);

            return(Quaternion.LookRotation(vec2));
        }