Beispiel #1
0
        private void CalculateAngle()
        {
            if (isAngleCalculated)
            {
                return;
            }

            hingeJointComponent.spring = new JointSpring
            {
                spring         = FIXABLE_FORCE,
                damper         = motorDamper,
                targetPosition = Vector3.SignedAngle
                                 (
                    transform.InverseTransformDirection(hingeBlock.connectedAttachment.transform.forward),
                    transform.InverseTransformDirection(hingeBlock.transform.forward),
                    VectorUtils.AbsVector3(hingeJointComponent.axis)
                                 )
            };
            DbLog.LogFormat("Blue vector: {0}", hingeBlock.connectedAttachment.transform.forward);
            DbLog.LogFormat("Red vector: {0}", hingeBlock.transform.forward);

            DbLog.LogFormat("New fixable angle: {0}", hingeJointComponent.spring.targetPosition);
            isAngleCalculated = true;
        }