Beispiel #1
0
        public static VRM10OffsetOnTransform Create(Transform transform)
        {
            var coordinate = new VRM10OffsetOnTransform
            {
                Transform = transform
            };

            if (transform != null)
            {
                coordinate.OffsetRotation = transform.worldToLocalMatrix.RotationToWorldAxis();
            }

            return(coordinate);
        }
Beispiel #2
0
        void Update()
        {
            if (Target != m_offsetTransform.Transform)
            {
                m_offsetTransform = VRM10OffsetOnTransform.Create(Target);
            }

            var target = m_offsetTransform.Transform;

            if (target != null)
            {
                var targetPosition = target.position + m_offset;
                transform.position = targetPosition + (m_offsetTransform.WorldMatrix.ExtractRotation() * Vector3.forward) * m_distance;
                transform.LookAt(targetPosition);
            }
        }