Ejemplo n.º 1
0
        public void OnNstStart()
        {
            if (nst != null)
            {
                hasAuthority = nst.na.IsMine;
            }

            // Find position and rotation elements that are defined for this child (assumes there are no more than one per, since there shouldn't be)
            if (nst != null && nst.nstElementsEngine != null)
            {
                foreach (TransformElement te in nst.nstElementsEngine.transformElements)
                {
                    if (te.gameobject == _gameObject)
                    {
                        if (te is IPositionElement)
                        {
                            pe = te as IPositionElement;
                        }
                        else if (te is IRotationElement)
                        {
                            re = te as IRotationElement;
                        }
                    }
                }
            }

            isQuat = (re != null && re.RotationType == RotationType.Quaternion);

            turnWithForce = isRootGO && rb != null && !rb.isKinematic && isQuat;
            moveWithForce = isRootGO && rb != null && !rb.isKinematic;

            // Set the restriction bools based on the restrict switch and the enabled/disabled axes
            if (restrictToNstRange)
            {
                if (pe != null)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        allowMove[i] = pe[i];
                    }
                }

                if (re != null && !isQuat)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        allowTurn[i] = re[i];
                    }
                }
            }
        }