コード例 #1
0
        public void ModifyRotateAroundZAxis()
        {
            MockVelocityTracker source = subject.gameObject.AddComponent <MockVelocityTracker>();

            subject.AngularVelocitySource = source;
            subject.ApplyToAxis           = Vector3State.ZOnly;

            GameObject unusedSource = new GameObject();
            GameObject target       = new GameObject();

            float rotationAngle = 90f;

            source.AngularVelocity    = Vector3.one * rotationAngle;
            target.transform.rotation = Quaternion.identity;

            Assert.AreEqual(Vector3.zero, target.transform.position);
            Assert.AreEqual(Quaternion.identity.ToString(), target.transform.rotation.ToString());

            subject.Modify(unusedSource, target);

            Assert.AreEqual(Vector3.zero, target.transform.position);
            Assert.AreEqual(Quaternion.Euler(Vector3.forward * rotationAngle).ToString(), target.transform.rotation.ToString());

            Object.DestroyImmediate(unusedSource);
            Object.DestroyImmediate(target);
        }
コード例 #2
0
        public void ModifyRotateAroundXAxisWithOffsetIgnored()
        {
            MockVelocityTracker source = subject.gameObject.AddComponent <MockVelocityTracker>();

            subject.AngularVelocitySource = source;
            subject.ApplyToAxis           = Vector3State.XOnly;
            subject.ApplyOffset           = false;

            GameObject unusedSource = new GameObject();
            GameObject target       = new GameObject();
            GameObject offset       = new GameObject();

            float rotationAngle = 90f;

            source.AngularVelocity    = Vector3.one * rotationAngle;
            target.transform.rotation = Quaternion.identity;
            offset.transform.position = new Vector3(0.5f, 0.5f, 0f);

            Assert.AreEqual(Vector3.zero, target.transform.position);
            Assert.AreEqual(Quaternion.identity.ToString(), target.transform.rotation.ToString());

            subject.Modify(unusedSource, target, offset);

            Assert.AreEqual(Vector3.zero, target.transform.position);
            Assert.AreEqual(Quaternion.Euler(Vector3.right * rotationAngle).ToString(), target.transform.rotation.ToString());

            Object.DestroyImmediate(unusedSource);
            Object.DestroyImmediate(target);
        }