コード例 #1
0
        private async UniTaskVoid Fire()
        {
            cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(this.GetCancellationTokenOnDestroy());
            distanceJoint2D         = tr.parent.gameObject.AddComponent <DistanceJoint2D>();
            distanceJoint2D.enabled = false;
            state = LassoState.Firing;
            await UniTask.Delay(TimeSpan.FromSeconds(settings.lifeTime), cancellationToken : cancellationTokenSource.Token);

            Destroy(gameObject);
        }
コード例 #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (isHookable(other))
     {
         cancellationTokenSource.Cancel();
         distanceJoint2D.connectedBody   = other.attachedRigidbody;
         distanceJoint2D.enableCollision = true;
         distanceJoint2D.enabled         = true;
         state = LassoState.Reeling;
         var otherTr = other.transform;
         lassoEnds.end = otherTr;
         tr.parent     = otherTr;
     }
 }