示例#1
0
        public virtual void OnColliderEventDragFixedUpdate(ColliderButtonEventData eventData)
        {
            if (eventData != grabbedEvent)
            {
                return;
            }

            if (moveByVelocity)
            {
                // if rigidbody exists, follow eventData caster using physics
                var casterPose = GetEventPose(eventData);
                var offsetPose = eventList.GetLastValue();

                if (alignPosition)
                {
                    offsetPose.pos = alignPositionOffset;
                }
                if (alignRotation)
                {
                    offsetPose.rot = Quaternion.Euler(alignRotationOffset);
                }

                var targetPose = casterPose * offsetPose;
                Pose.SetRigidbodyVelocity(rigid, rigid.position, targetPose.pos, followingDuration);
                Pose.SetRigidbodyAngularVelocity(rigid, rigid.rotation, targetPose.rot, followingDuration, overrideMaxAngularVelocity);
            }
        }
 protected virtual void FixedUpdate()
 {
     if (isPoseValid)
     {
         Pose.SetRigidbodyVelocity(rigid, rigid.position, targetPose.pos, followingDuration);
         Pose.SetRigidbodyAngularVelocity(rigid, rigid.rotation, targetPose.rot, followingDuration);
     }
     else
     {
         rigid.velocity        = Vector3.zero;
         rigid.angularVelocity = Vector3.zero;
     }
 }
示例#3
0
        protected void DoDrop()
        {
            if (!moveByVelocity && rigid != null && !rigid.isKinematic && m_prevPose != Pose.identity)
            {
                Pose.SetRigidbodyVelocity(rigid, m_prevPose.pos, transform.position, Time.deltaTime);
                Pose.SetRigidbodyAngularVelocity(rigid, m_prevPose.rot, transform.rotation, Time.deltaTime, overrideMaxAngularVelocity);

                m_prevPose = Pose.identity;
            }

            if (onDrop != null)
            {
                onDrop.Invoke(this);
            }
        }