public override void TrackBegin(Grabber grabber, GrabPointProvider pointProvider)
        {
            Rigidbody.isKinematic      = GrabFlags.HasFlag(EGrabPhysicsFlags.IsKinematic);
            Rigidbody.detectCollisions = GrabFlags.HasFlag(EGrabPhysicsFlags.Collision);
            Rigidbody.useGravity       = GrabFlags.HasFlag(EGrabPhysicsFlags.UseGravity);

            Rigidbody.velocity        = Vector3.zero;
            Rigidbody.angularVelocity = Vector3.zero;
        }
        public override void TrackBegin(Grabber grabber, GrabPointProvider pointProvider)
        {
            _parent = transform.parent;

            if (ParentToPoint)
            {
                transform.SetParent(pointProvider.Point);
            }
        }
Пример #3
0
        public override void Grabbing(Grabber grabber)
        {
            var delta = grabber.transform.position - _grabLastPosition;

            if (delta.sqrMagnitude >= UpdateStep)
            {
                _grabLastPosition = grabber.transform.position;
                OnMove.Invoke(delta, _grabStartPosition, grabber.transform.position);
            }
        }
Пример #4
0
        public override void Grabbing(Grabber grabber)
        {
            base.Grabbing(grabber);

            if (Point == null || Sync == null)
            {
                return;
            }

            Sync.Track(grabber, PointProvider);
        }
        public override void TrackEnd(Grabber grabber, GrabPointProvider pointProvider)
        {
            Rigidbody.isKinematic      = UnGrabFlags.HasFlag(EGrabPhysicsFlags.IsKinematic);
            Rigidbody.detectCollisions = UnGrabFlags.HasFlag(EGrabPhysicsFlags.Collision);
            Rigidbody.useGravity       = UnGrabFlags.HasFlag(EGrabPhysicsFlags.UseGravity);

            if (ThrowSensitivity > 0)
            {
                var velocity = grabber.VelocityEstimator.Velocity;
                Rigidbody.velocity = velocity * ThrowSensitivity;
            }
        }
        public override void Track(Grabber grabber, GrabPointProvider pointProvider)
        {
            if (ParentToPoint)
            {
                return;
            }

            var point = pointProvider.Point;

            transform.position = point.position;
            transform.rotation = point.rotation;
        }
Пример #7
0
        public virtual void Grabbed(Grabber grabber)
        {
            PointProvider = grabber.GrabPointProvidersTable[GrabPointMarker];
            IsGrabbing    = true;

            if (GrabFlags.HasFlag(EGrabFlags.SnapPosition))
            {
                transform.position = Point.position;
            }

            if (GrabFlags.HasFlag(EGrabFlags.SnapRotation))
            {
                transform.localRotation = Point.rotation;
            }

            OnGrabbed.Invoke(grabber);
        }
        public override void Track(Grabber grabber, GrabPointProvider pointProvider)
        {
            var point     = pointProvider.Point;
            var direction = point.position - transform.position;

            direction.Normalize();

            var distance    = Vector3.Distance(transform.position, point.position);
            var outputSpeed = Mathf.Lerp(0, Speed, Curve.Evaluate(distance));

            Rigidbody.position += direction * outputSpeed * Time.fixedDeltaTime;

            if (SyncRotation)
            {
                Rigidbody.rotation = point.rotation;
            }
        }
Пример #9
0
 private void OnMoveBegin(Grabber grabber)
 {
 }
Пример #10
0
 public virtual void UnGrabbed(Grabber grabber)
 {
     OnUnGrabbed.Invoke(grabber);
     PointProvider = null;
     IsGrabbing    = false;
 }
Пример #11
0
 public virtual void Grabbing(Grabber grabber)
 {
     OnGrabbing.Invoke(grabber);
 }
Пример #12
0
 public override void UnGrabbed(Grabber grabber)
 {
 }
Пример #13
0
        public override void UnGrabbed(Grabber grabber)
        {
            base.UnGrabbed(grabber);

            Sync?.TrackEnd(grabber, PointProvider);
        }
Пример #14
0
        public override void Grabbed(Grabber grabber)
        {
            base.Grabbed(grabber);

            Sync?.TrackBegin(grabber, PointProvider);
        }
 public abstract void TrackBegin(Grabber grabber, GrabPointProvider pointProvider);
 public override void TrackEnd(Grabber grabber, GrabPointProvider pointProvider)
 {
     transform.SetParent(_parent);
 }