예제 #1
0
            public void Update(InteractionSystem interactionSystem)
            {
                if (!this.initiated)
                {
                    return;
                }
                Vector3 vector = this.spherecastFrom.TransformDirection(this.raycastDirectionLocal);

                this.hit.point = this.spherecastFrom.position + vector;
                bool flag = this.FindWalls(vector);

                if (!this.inTouch)
                {
                    if (flag && Time.time > this.nextSwitchTime)
                    {
                        this.interactionObject.transform.parent = null;
                        interactionSystem.StartInteraction(this.effectorType, this.interactionObject, true);
                        this.nextSwitchTime = Time.time + this.minSwitchTime;
                        this.targetPosition = this.hit.point;
                        this.targetRotation = Quaternion.LookRotation(-this.hit.normal);
                        this.interactionObject.transform.position = this.targetPosition;
                        this.interactionObject.transform.rotation = this.targetRotation;
                    }
                }
                else
                {
                    if (!flag)
                    {
                        this.StopTouch(interactionSystem);
                    }
                    else if (!interactionSystem.IsPaused(this.effectorType) || this.sliding)
                    {
                        this.targetPosition = this.hit.point;
                        this.targetRotation = Quaternion.LookRotation(-this.hit.normal);
                    }
                    if (Vector3.Distance(this.interactionObject.transform.position, this.hit.point) > this.releaseDistance)
                    {
                        if (flag)
                        {
                            this.targetPosition = this.hit.point;
                            this.targetRotation = Quaternion.LookRotation(-this.hit.normal);
                        }
                        else
                        {
                            this.StopTouch(interactionSystem);
                        }
                    }
                }
                float b = (this.inTouch && (!interactionSystem.IsPaused(this.effectorType) || !(this.interactionObject.transform.position == this.targetPosition))) ? 1f : 0f;

                this.speedF = Mathf.Lerp(this.speedF, b, Time.deltaTime * 3f);
                this.interactionObject.transform.position = Vector3.Lerp(this.interactionObject.transform.position, this.targetPosition, Time.deltaTime * this.lerpSpeed * this.speedF);
                this.interactionObject.transform.rotation = Quaternion.Slerp(this.interactionObject.transform.rotation, this.targetRotation, Time.deltaTime * this.lerpSpeed * this.speedF);
            }
예제 #2
0
        void OnGUI()
        {
            if (interactionSystem == null)
            {
                return;
            }

            if (GUILayout.Button("Start Interaction With " + interactionObject.name))
            {
                if (effectors.Length == 0)
                {
                    Debug.Log("Please select the effectors to interact with.");
                }

                foreach (FullBodyBipedEffector e in effectors)
                {
                    interactionSystem.StartInteraction(e, interactionObject, true);
                }
            }

            if (effectors.Length == 0)
            {
                return;
            }

            if (interactionSystem.IsPaused(effectors[0]))
            {
                if (GUILayout.Button("Resume Interaction With " + interactionObject.name))
                {
                    interactionSystem.ResumeAll();
                }
            }
        }
예제 #3
0
        public void EndInteraction(bool immediately = false)
        {
            if (null != m_CasterInteractionSystem)
            {
                for (int i = 0; i < casterEffectors.Length; i++)
                {
                    if (immediately || !m_CasterInteractionSystem.IsPaused(casterEffectors[i]))
                    {
                        m_CasterInteractionSystem.StopInteraction(casterEffectors[i]);
                    }
                    else
                    {
                        m_CasterInteractionSystem.ResumeInteraction(casterEffectors[i]);
                    }
                }
            }

            if (null != m_TargetInteractionSystem)
            {
                for (int i = 0; i < targetEffectors.Length; i++)
                {
                    if (immediately)
                    {
                        m_TargetInteractionSystem.StopInteraction(targetEffectors[i]);
                    }
                    else
                    {
                        m_TargetInteractionSystem.ResumeInteraction(targetEffectors[i]);
                    }
                }
            }
        }
예제 #4
0
            /// <summary>
            /// Checks if the system is currently interacting with/grabbing this object.
            /// </summary>
            /// <returns>bool</returns>
            private bool IsGrabbingObject()
            {
                // First check if interacting with this object
                if (interactionSystem.GetInteractionObject(effectorType) == interactionObject)
                {
                    // Next check if we are grabbing the object (interaction is active but paused)
                    if (interactionSystem.IsPaused(effectorType))
                    {
                        return(true);
                    }
                }

                return(false);
            }
예제 #5
0
 private void StopTouch(InteractionSystem interactionSystem)
 {
     this.interactionObject.transform.parent = interactionSystem.transform;
     this.nextSwitchTime = Time.time + this.minSwitchTime;
     if (interactionSystem.IsPaused(this.effectorType))
     {
         interactionSystem.ResumeInteraction(this.effectorType);
     }
     else
     {
         this.speedF         = 0f;
         this.targetPosition = this.hit.point;
         this.targetRotation = Quaternion.LookRotation(-this.hit.normal);
     }
 }
예제 #6
0
            // Stop touching the walls
            private void StopTouch(InteractionSystem interactionSystem)
            {
                interactionObject.transform.parent = interactionSystem.transform;
                nextSwitchTime = Time.time + minSwitchTime / interactionSystem.speed;

                if (interactionSystem.IsPaused(effectorType))
                {
                    interactionSystem.ResumeInteraction(effectorType);
                }
                else
                {
                    speedF         = 0f;
                    targetPosition = hit.point;
                    targetRotation = Quaternion.LookRotation(-hit.normal);
                }
            }
        public float enableInputAtProgress = 0.8f;              // The normalized interaction progress after which the character is able to move again

        protected override void Update()
        {
            // Disable input when in interaction
            if (disableInputInInteraction && interactionSystem != null && (interactionSystem.inInteraction || interactionSystem.IsPaused()))
            {
                // Get the least interaction progress
                float progress = interactionSystem.GetMinActiveProgress();

                // Keep the character in place
                if (progress > 0f && progress < enableInputAtProgress)
                {
                    state.move = Vector3.zero;
                    state.jump = false;
                    return;
                }
            }

            // Pass on the FixedUpdate call
            base.Update();
        }
예제 #8
0
    void FixedUpdate()
    {
        //update points to attach points
        if (StartAttachPoint != null && EndAttachPoint != null)
        {
            if (EndPoint != null && StartPoint != null)
            {
                StartPoint.position = StartAttachPoint.position;
                EndPoint.position   = EndAttachPoint.position;
            }
            else
            {
//				print ("null 1");
            }
        }
        else
        {
//			print ("null 2");
        }

        //draw rope with line renderer
        drawRope();

        updateCollider();

        _currentRopeDistance = Vector3.Distance(StartPoint.position, EndPoint.position);

        if (!photonView.isMine)
        {
            return;
        }

        //null mean death(destroyed target)?
        if (EndPoint == null || StartPoint == null)
        {
            Destroy();
            return;
        }

        if (StartTarget != null)
        {
            if (StartTarget.GetComponent <CharacterMovementHandler> ())
            {
                _grounded = StartTarget.GetComponent <CharacterMovementHandler> ().IsGrounded;
            }
            else
            {
                _grounded = true;
            }
        }

        if (EndPoint.position.y > StartPoint.position.y + 0.5f)
        {
            _isEndPointHigher = true;
        }
        else
        {
            _isEndPointHigher = false;
        }

        if (_intSys != null)
        {
            if (_grounded)
            {
                _intSys.ResumeInteraction(FullBodyBipedEffector.RightHand);
            }
            else if (_isEndPointHigher && !_intSys.IsInInteraction(FullBodyBipedEffector.RightHand) && !_intSys.IsPaused())
            {
                _intSys.StartInteraction(RootMotion.FinalIK.FullBodyBipedEffector.RightHand, _handGrabTarget, true);
            }
        }
        //update raycasted version of the rope
        if (IsSetup)
        {
            tether();
        }

        //position hand grab target
        _handGrabTarget.transform.position = StartPoint.position + (EndPoint.position - StartPoint.position).normalized * 0.5f;
        _handGrabTarget.transform.LookAt(EndPoint);
        _handGrabTarget.transform.Rotate(new Vector3(90f, 0f, 0f));

//		//draw rope with line renderer
//		drawRope ();

//		updateCollider ();

        checkForBending();
    }
예제 #9
0
            // Update this instance
            public void Update(InteractionSystem interactionSystem)
            {
                if (!initiated)
                {
                    return;
                }

                // The default position
                Vector3 direction = spherecastFrom.TransformDirection(raycastDirectionLocal);

                hit.point = spherecastFrom.position + direction;

                // Spherecasting
                bool wallFound = FindWalls(direction);

                // Starting and ending the interactions
                if (!inTouch)
                {
                    if (wallFound && Time.time > nextSwitchTime)
                    {
                        interactionObject.transform.parent = null;
                        interactionSystem.StartInteraction(effectorType, interactionObject, true);
                        nextSwitchTime = Time.time + minSwitchTime / interactionSystem.speed;

                        targetPosition = hit.point;
                        targetRotation = Quaternion.LookRotation(-hit.normal);

                        interactionObject.transform.position = targetPosition;
                        interactionObject.transform.rotation = targetRotation;
                    }
                }
                else
                {
                    if (!wallFound)
                    {
                        // Resume if no wall found
                        StopTouch(interactionSystem);
                    }
                    else
                    {
                        if (!interactionSystem.IsPaused(effectorType) || sliding)
                        {
                            targetPosition = hit.point;
                            targetRotation = Quaternion.LookRotation(-hit.normal);
                        }
                    }

                    if (Vector3.Distance(interactionObject.transform.position, hit.point) > releaseDistance)
                    {
                        if (wallFound)
                        {
                            targetPosition = hit.point;
                            targetRotation = Quaternion.LookRotation(-hit.normal);
                        }
                        else
                        {
                            StopTouch(interactionSystem);
                        }
                    }
                }

                float speedFTarget = !inTouch || (interactionSystem.IsPaused(effectorType) && interactionObject.transform.position == targetPosition)? 0f: 1f;

                speedF = Mathf.Lerp(speedF, speedFTarget, Time.deltaTime * 3f * interactionSystem.speed);

                // Interpolating the interaction object
                float s = Time.deltaTime * lerpSpeed * speedF * interactionSystem.speed;

                interactionObject.transform.position = Vector3.Lerp(interactionObject.transform.position, targetPosition, s);
                interactionObject.transform.rotation = Quaternion.Slerp(interactionObject.transform.rotation, targetRotation, s);
            }