protected override void ApplyToAttached()
        {
            ApplyToSector();
            if (!ReferenceTransform)
            {
                return;
            }

            if (IsPlayerObject)
            {
                if (UseInterpolation)
                {
                    AttachedTransform.localPosition = SmoothPosition;
                    AttachedTransform.localRotation = SmoothRotation;
                }
                else
                {
                    AttachedTransform.localPosition = transform.position;
                    AttachedTransform.localRotation = transform.rotation;
                }
            }
            else
            {
                if (UseInterpolation)
                {
                    AttachedTransform.position = ReferenceTransform.FromRelPos(SmoothPosition);
                    AttachedTransform.rotation = ReferenceTransform.FromRelRot(SmoothRotation);
                }
                else
                {
                    AttachedTransform.position = ReferenceTransform.FromRelPos(transform.position);
                    AttachedTransform.rotation = ReferenceTransform.FromRelRot(transform.rotation);
                }
            }
        }
        /// Dont do base... this is a replacement!
        protected override void ApplyToAttached()
        {
            ApplyToSector();
            if (!ReferenceTransform)
            {
                return;
            }

            var targetPos = ReferenceTransform.FromRelPos(transform.position);

            _updateCount++;
            if (_updateCount >= ForcePositionAfterUpdates)
            {
                _updateCount = 0;

                var targetRot = ReferenceTransform.FromRelRot(transform.rotation);

                AttachedRigidbody.SetPosition(targetPos);
                AttachedRigidbody.SetRotation(targetRot);
            }

            var targetVelocity        = ReferenceRigidbody.FromRelVel(Velocity, targetPos);
            var targetAngularVelocity = ReferenceRigidbody.FromRelAngVel(AngularVelocity);

            SetVelocity(AttachedRigidbody, targetVelocity);
            AttachedRigidbody.SetAngularVelocity(targetAngularVelocity);
        }
Пример #3
0
        protected override void ApplyToAttached()
        {
            ApplyToSector();
            if (!ReferenceTransform)
            {
                return;
            }

            var targetPos = ReferenceTransform.FromRelPos(transform.position);
            var targetRot = ReferenceTransform.FromRelRot(transform.rotation);

            var positionToSet = targetPos;
            var rotationToSet = targetRot;

            if (UseInterpolation)
            {
                positionToSet = ReferenceTransform.FromRelPos(SmoothPosition);
                rotationToSet = ReferenceTransform.FromRelRot(SmoothRotation);
            }

            AttachedRigidbody.MoveToPosition(positionToSet);
            AttachedRigidbody.MoveToRotation(rotationToSet);

            var targetVelocity        = ReferenceRigidbody.FromRelVel(Velocity, targetPos);
            var targetAngularVelocity = ReferenceRigidbody.FromRelAngVel(AngularVelocity);

            AttachedRigidbody.SetVelocity(targetVelocity);
            AttachedRigidbody.SetAngularVelocity(targetAngularVelocity);
        }
        protected virtual void OnRenderObject()
        {
            if (!QSBCore.DebugSettings.DrawLines ||
                !IsValid ||
                !ReferenceTransform)
            {
                return;
            }

            /* Red Cube = Where visible object should be
             * Green cube = Where visible object is
             * Magenta cube = Reference transform
             * Red Line = Connection between Red Cube and Green Cube
             * Cyan Line = Connection between Green cube and reference transform
             */

            Popcron.Gizmos.Cube(ReferenceTransform.FromRelPos(transform.position), ReferenceTransform.FromRelRot(transform.rotation), Vector3.one / 8, Color.red);
            Popcron.Gizmos.Line(ReferenceTransform.FromRelPos(transform.position), AttachedTransform.transform.position, Color.red);
            Popcron.Gizmos.Cube(AttachedTransform.transform.position, AttachedTransform.transform.rotation, Vector3.one / 6, Color.green);
            Popcron.Gizmos.Cube(ReferenceTransform.position, ReferenceTransform.rotation, Vector3.one / 8, Color.magenta);
            Popcron.Gizmos.Line(AttachedTransform.transform.position, ReferenceTransform.position, Color.cyan);
        }