Beispiel #1
0
 public float PickUpObject(InteractionObject whichIO)
 {
     if (!holding)
     {
         interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, whichIO, false);
         interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, whichIO, false);
     }
     ObjectWhenUpright = whichIO.transform.localEulerAngles;
     return(holdWeight);    // lerps from 0 to 1
 }
Beispiel #2
0
        public override void StartInteraction(InteractionSystem interactionSystem)
        {
            base.StartInteraction(interactionSystem);
            Debug.Log("start box interraction");
            m_InteractionSystem = interactionSystem;
            m_InteractionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, m_finalIKInteractionObject, true);
            m_InteractionSystem.StartInteraction(FullBodyBipedEffector.RightHand, m_finalIKInteractionObject, true);

            if (m_onStartInteractionEvent != null)
            {
                m_onStartInteractionEvent.Invoke();
            }

            MovePlayerToRightPos();
        }
    void StartGrabAnimation(PropBaseModel model)
    {
        InteractionObject _obj = model.mInteractionObject;

        interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, _obj, false);
        interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, _obj, false);
        if (model.prop.name == PropName.M416)
        {
            animator.SetLayerWeight(1, 1);
        }
        else
        {
            animator.SetLayerWeight(1, 0);
        }
    }
Beispiel #4
0
 public void openDoor(InteractionSystem system, FullBodyBipedEffector[] effector, InteractionObject obj)
 {
     foreach (FullBodyBipedEffector e in effector)
     {
         system.StartInteraction(e, obj, true);
     }
 }
Beispiel #5
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();
                }
            }
        }
        public override void StartInteraction(InteractionSystem interactionSystem)
        {
            if (m_isInInteraction)
            {
                return;
            }
            m_InteractionSystem = interactionSystem;
            m_isInInteraction   = true;

            m_laddderUpGateCollider.enabled = false;
            SetInteractionTargetPivotPosition();

            m_InteractionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, m_finalIKInteractionObject, true);
            m_InteractionSystem.StartInteraction(FullBodyBipedEffector.RightHand, m_finalIKInteractionObject, true);

            MovePlayerToRightPosAndStartInteract();
        }
        public override void StartInteraction(InteractionSystem interactionSystem)
        {
            if (!m_enableInteraction)
            {
                return;
            }

            base.StartInteraction(interactionSystem);
            m_InteractionSystem = interactionSystem;
            m_InteractionSystem.StartInteraction(FullBodyBipedEffector.RightHand, m_finalIKInteractionObject, true);
        }
Beispiel #8
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);
            }
Beispiel #9
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("E键按下");
            foreach (FullBodyBipedEffector e in effectors)
            {
                interactionSystem.StartInteraction(e, interactionObject, true);
            }
        }

        if (Input.GetKeyDown(KeyCode.R) || Input.GetMouseButtonDown(0))
        {
            Debug.Log("R键按下");
            recoil.Fire(magnitude);
        }
    }
Beispiel #10
0
        void DoStart()
        {
            if (null != m_CasterInteractionSystem && null != m_TargetInteractionObj)
            {
                for (int i = 0; i < casterEffectors.Length; i++)
                {
                    m_CasterInteractionSystem.StartInteraction(casterEffectors[i], m_TargetInteractionObj, false);
                }
            }

            if (null != m_TargetInteractionSystem && null != m_CasterInteractionObj)
            {
                for (int i = 0; i < targetEffectors.Length; i++)
                {
                    m_TargetInteractionSystem.StartInteraction(targetEffectors[i], m_CasterInteractionObj, false);
                }
            }
        }
Beispiel #11
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("E键按下");
            foreach (FullBodyBipedEffector e in effectors)
            {
                interactionSystem.StartInteraction(e, interactionObject, true);
                mAimIK.solver.transform        = interactionObject.transform.Find("Gun/FBXExport_Props:MP40/AimTransform");
                mAimIK.solver.IKPositionWeight = 1f;
            }
        }

        if (Input.GetKeyDown(KeyCode.R) || Input.GetMouseButtonDown(0))
        {
            Debug.Log("R键按下");
            recoil.Fire(magnitude);
        }

        mAimIK.solver.IKPosition = transform.forward * 10f;
        mAimIK.solver.Update();
    }
Beispiel #12
0
    void Update()
    {
        // sitting.RunButtCheck();
        interactionSystem.ik.solver.rightLegChain.bendConstraint.weight = interactionSystem.ik.solver.bodyEffector.positionWeight;
        interactionSystem.ik.solver.leftLegChain.bendConstraint.weight  = interactionSystem.ik.solver.bodyEffector.positionWeight;

        if (isSitting)
        {
            if (!interactionSystem.inInteraction && Input.GetButtonDown("WXButton1"))
            {
                interactionSystem.ResumeAll();

                isSitting = false;
            }

            return;
        }

        if (!interactionSystem.inInteraction && Input.GetButtonDown("WXButton1"))
        {
            print("test");
            sitting.RunButtCheck();
            //Body
            interactionSystem.StartInteraction(FullBodyBipedEffector.Body, sittingMain, interrupt);
            //Left Leg
            //interactionSystem.StartInteraction(FullBodyBipedEffector.LeftThigh, sittingMain, interrupt);
            interactionSystem.ik.solver.leftLegChain.bendConstraint.bendGoal = leftThighBendTarget;
            interactionSystem.ik.solver.leftLegChain.bendConstraint.weight   = interactionSystem.ik.solver.bodyEffector.positionWeight;
            //Right Leg
            //interactionSystem.StartInteraction(FullBodyBipedEffector.RightThigh, sittingMain, interrupt);
            interactionSystem.ik.solver.rightLegChain.bendConstraint.bendGoal = rightThighBendTarget;
            interactionSystem.ik.solver.rightLegChain.bendConstraint.weight   = interactionSystem.ik.solver.bodyEffector.positionWeight;

            //Left Hand
            interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, sittingLeftHand, interrupt);
            //RightnHand
            interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, sittingRightHand, interrupt);

            //interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, benchHands, interrupt);

            isSitting = true;
        }
    }
        // GUI for calling the interactions
        void OnGUI()
        {
            interrupt = GUILayout.Toggle(interrupt, "Interrupt");

            // While seated
            if (isSitting)
            {
                if (!interactionSystem.inInteraction && GUILayout.Button("Stand Up"))
                {
                    interactionSystem.ResumeAll();

                    isSitting = false;
                }

                return;
            }

            // While standing

            if (GUILayout.Button("Pick Up Ball"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, ball, interrupt);
            }

            if (GUILayout.Button("Button Left Hand"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, button, interrupt);
            }

            if (GUILayout.Button("Button Right Hand"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, button, interrupt);
            }

            if (GUILayout.Button("Put Out Cigarette"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightFoot, cigarette, interrupt);
            }

            if (GUILayout.Button("Open Door"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, door, interrupt);
            }

            // This is a multiple-effector interaction
            if (!interactionSystem.inInteraction && GUILayout.Button("Sit Down"))
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.Body, benchMain, interrupt);
                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftThigh, benchMain, interrupt);
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightThigh, benchMain, interrupt);
                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftFoot, benchMain, interrupt);

                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, benchHands, interrupt);
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, benchHands, interrupt);

                isSitting = true;
            }
        }
 void PlayInteractionNow()
 {
     interactionSystem.StartInteraction(effector, interactionObject, true);
 }
Beispiel #15
0
    // Update is called once per frame
    void Update()
    {
        //x.x = Screen.width / 2;
        //x.y = Screen.height / 2;

        //RaycastHit inRange;

        //if (Physics.Raycast(MainCamera.ViewportPointToRay(x), out inRange, 5)) {
        //	if (inRange.distance <= 5 && inRange.collider.gameObject.tag == "PickUp") {
        //		Debug.Log ("Near");
        //		nearItem = true;
        //		lookTarget.solver.IKPosition = inRange.collider.transform.position;

        //	}
        //} else {
        //	nearItem = false;
        //}


        if (Input.GetKeyDown(KeyCode.G) && nearItem)
        {
            ik.enabled = true;
            nearItem   = false;
            //lookTarget.solver.IKPosition = lookAtPickup;
            foreach (FullBodyBipedEffector e in effectors)
            {
                interactionSystem.StartInteraction(e, interactionObject, true);
            }
            pickedUp = true;
        }

        //If Camera is picked up, move camera to target position in front of face
        if (!interactionSystem.inInteraction && pickedUp)
        {
            //Smoothing, don't know why there's stutter if this is ommitted.
            if (targetItem.parent.name != "EYE_DEF")
            {
                targetItem.localPosition = new Vector3(.06f, 0, 0);
            }

            //Reset LookAt Weight to 1f because pick up sets it to 0
            lookTarget.solver.SetLookAtWeight(1f, 0.5f, 1f, 1f, 0.5f, 0.5f, 0.5f);

            targetItem.SetParent(head.FindChild("EYE_DEF"));
            targetItem.localPosition = Vector3.Slerp(targetItem.localPosition, targetMove.localPosition, 10f * Time.deltaTime);
            targetItem.localRotation = Quaternion.Lerp(targetItem.localRotation, targetMove.localRotation, 10f * Time.deltaTime);

            //If hand and camera are almost in position, set the position to the default target position
            if (Mathf.Abs(targetItem.localPosition.x - targetMove.localPosition.x) < 0.001)
            {
                targetItem.localPosition = targetMove.localPosition;
                targetItem.localRotation = targetMove.localRotation;
                targetMove.gameObject.SetActive(true);
                GameObject.Find("First Person Controller").transform.FindChild("unitychan").GetComponent <HeadRotation>().targetHand = targetMove.transform.FindChild("DefaultPos").transform;
                pickedUp = false;
                Destroy(targetItem.gameObject);
                //Destroy (destroyItems[0].gameObject);
                Destroy(destroyItems[1].gameObject);
            }
        }
    }
Beispiel #16
0
    private void Update()
    {
        if (h3 == true)
        {
            shake += Time.deltaTime;

            if (shake % 1 > 0.5f)
            {
                scene.items[ans].SetActive(true);
            }
            else
            {
                scene.items[ans].SetActive(false);
            }
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            if (target.transform.position.x < scene.NPC.transform.position.x)
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, target, interrupt);
            }
            else if (target.transform.position.x > scene.NPC.transform.position.x)
            {
                interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, target, interrupt);
            }
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            interactionSystem.lookAt.Look(target.transform, Time.time + (target.length * 0.5f));
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            //record.selectObject(scene.items[0], stage, hint);
            select = UnityEngine.Random.Range(0, 6);;
            scene.YesOrNo.transform.position = new Vector3(scene.items[select].transform.position.x, scene.items[select].gameObject.transform.position.y + float.Parse("0.5"), 2);
            scene.YesOrNo.SetActive(true);
            foreach (GameObject it in scene.yes_no)
            {
                it.SetActive(true);
            }
            scene.yes_no[0].gameObject.transform.position = new Vector3(scene.items[select].gameObject.transform.position.x - float.Parse("0.5"), scene.items[select].gameObject.transform.position.y, scene.items[select].gameObject.transform.position.z);
            scene.yes_no[1].gameObject.transform.position = new Vector3(scene.items[select].gameObject.transform.position.x + float.Parse("0.5"), scene.items[select].gameObject.transform.position.y, scene.items[select].gameObject.transform.position.z);
        }


        /*ansObj = scene.items[ans];
         *
         * target.transform.position = ansObj.transform.position;
         *
         * Vector3 targetDir = ansObj.transform.position - eye.transform.position;
         * float angle = Vector3.Angle(targetDir, ansObj.transform.forward);
         *
         * if (ansObj.transform.position.x > scene.NPC.transform.position.x)
         * {
         *  scene.arrowL.transform.position = (ansObj.transform.position + eye.transform.position) / 2;
         *  scene.arrowL.transform.rotation = Quaternion.Euler(0f, 0f, 90 - angle);
         * }
         * else if (ansObj.transform.position.x < scene.NPC.transform.position.x)
         * {
         *  scene.arrowR.transform.position = (ansObj.transform.position + eye.transform.position) / 2;
         *  scene.arrowR.transform.rotation = Quaternion.Euler(0f, 0f, 90 - angle);
         * }*/
    }
Beispiel #17
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();
    }
        public override void StartInteraction(InteractionSystem interactionSystem)
        {
            if (m_currentInteractionTrigger.TriggerID == m_pickTirggerID)
            {
                if (!m_enableInteraction || m_pickedTheObject)
                {
                    return;
                }

                base.StartInteraction(interactionSystem);
                m_InteractionSystem = interactionSystem;
                m_InteractionSystem.StartInteraction(FullBodyBipedEffector.RightHand, m_finalIKInteractionObject, true);
                if (m_useLeftHand)
                {
                    m_InteractionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, m_finalIKInteractionObject, true);
                }

                m_pickedTheObject = true;

                if (m_onPickEvent != null)
                {
                    m_onPickEvent.Invoke();
                }
            }

            if (m_currentInteractionTrigger.TriggerID == m_dropTriggerID)
            {
                if (m_pickedTheObject)
                {
                    var poser = transform.parent.GetComponent <Poser>();
                    if (poser != null)
                    {
                        poser.poseRoot = null;
                        poser.weight   = 0f;
                    }

                    DropedTheObeject();
                    transform.parent = null;
                    m_player.SetRightArmEffector(1.0f, this.transform);
                    transform.DOMove(m_dropPosition.position, 1.0f).OnComplete(() =>
                    {
                        float myFloat = 1.0f;
                        DOTween.To(() => myFloat, x => myFloat = x, 0.0f, 2.0f).OnUpdate(() => { m_player.SetRightArmEffector(myFloat, null); }).SetOptions(false);

                        if (m_onDropEvent != null)
                        {
                            m_onDropEvent.Invoke();
                        }
                        if (m_onInteractionComplete != null)
                        {
                            m_onInteractionComplete.Invoke();
                        }
                    });
                }

                //if (!m_enableInteraction) return;
                //base.StartInteraction(interactionSystem);
                //m_InteractionSystem = interactionSystem;
                //m_InteractionSystem.StartInteraction(FullBodyBipedEffector.RightHand, m_finalIKInteractionObject, true);
            }
        }
    void HandlePlayer(GameObject CurrentPerson, int PlayerNumber)
    {
        GameObject collectObject;
        GameObject PowerObject;
        Vector3    Zombiediff;
        Vector3    Zombie1diff;
        Vector3    Playerdiff;
        Vector3    PowerDiff;
        int        randomnumber;

        collectObject = NearestObjectByTag("Collectable", CurrentPerson.transform.position);
        if (collectObject == null)
        {
            UserWins();
        }
        Vector3 Positiondiff = collectObject.transform.position - CurrentPerson.transform.position;
        float   DistanceAway = Positiondiff.sqrMagnitude;

        if (PlayerNumber != playerNum.Value)
        {
            if (CurrentPerson.GetComponent <SteeringController> ().IsAtTarget() || CurrentPerson.GetComponent <SteeringController> ().IsStopped())
            {
                CurrentPerson.GetComponent <SteeringController> ().Target = new Vector3(Random.Range(248f, 259f), 0.1f, Random.Range(1142f, 1169f));
            }
            return;
        }

        InteractionSystem playerIS = player.Value.GetComponent <InteractionSystem>();

        PowerObject = NearestObjectByTag("PowerUp", CurrentPerson.transform.position);

        if (PowerObject != null)
        {
            PowerDiff = PowerObject.transform.position - CurrentPerson.transform.position;
            if (PowerDiff.sqrMagnitude < 3 && MusicInt.Value == 0)
            {
                playerIS.StartInteraction(FullBodyBipedEffector.RightHand, PowerObject.GetComponent <InteractionObject>(), false);

                MusicInt = Val.V(() => 1);

                PowerObject.SetActive(false);
            }
        }

        if (cameraOn.Value == 1)
        {
            Zombiediff        = zombie.transform.position - player.Value.transform.position;
            Zombie1diff       = zombie1.transform.position - player.Value.transform.position;
            Playerdiff        = new Vector3(0, 0, 0);
            FirstZombie.text  = "First Zombie: " + (int)Zombiediff.sqrMagnitude;
            SecondZombie.text = "Second Zombie: " + (int)Zombie1diff.sqrMagnitude;
            PlayerText.text   = "Player: " + (int)Playerdiff.sqrMagnitude;

            FirstZombie.enabled  = true;
            SecondZombie.enabled = true;
            PlayerText.enabled   = true;
        }
        if (cameraOn.Value == 2)
        {
            Zombiediff        = new Vector3(0, 0, 0);
            Zombie1diff       = zombie1.transform.position - zombie.transform.position;
            Playerdiff        = player.Value.transform.position - zombie.transform.position;
            FirstZombie.text  = "First Zombie: " + (int)Zombiediff.sqrMagnitude;
            SecondZombie.text = "Second Zombie: " + (int)Zombie1diff.sqrMagnitude;
            PlayerText.text   = "Player: " + (int)Playerdiff.sqrMagnitude;

            FirstZombie.enabled  = true;
            SecondZombie.enabled = true;
            PlayerText.enabled   = true;
        }
        if (cameraOn.Value == 3)
        {
            Zombiediff        = zombie.transform.position - zombie1.transform.position;
            Zombie1diff       = new Vector3(0, 0, 0);
            Playerdiff        = player.Value.transform.position - zombie1.transform.position;
            FirstZombie.text  = "First Zombie: " + (int)Zombiediff.sqrMagnitude;
            SecondZombie.text = "Second Zombie: " + (int)Zombie1diff.sqrMagnitude;
            PlayerText.text   = "Player: " + (int)Playerdiff.sqrMagnitude;

            FirstZombie.enabled  = true;
            SecondZombie.enabled = true;
            PlayerText.enabled   = true;
        }
        if (cameraOn.Value == 1 && UserControl.Value == true)
        {
            if (DistanceAway < 4)
            {
                collectObject.SetActive(false);
            }

            return;
        }

        if (PlayerNumber == playerNum.Value)
        {
            if (CurrentPerson.GetComponent <CharacterMecanim> ().Body.NavCanReach(collectObject.transform.position) == false)
            {
                CurrentPerson.GetComponent <SteeringController> ().Target = DoorOpenPoint.position;
            }
            else
            {
                if (DistanceAway < 3)
                {
                    collectObject.SetActive(false);
                }
                else
                {
                    CurrentPerson.GetComponent <SteeringController> ().Target = collectObject.transform.position;
                }
            }
        }
        else
        {
            return;
        }
    }
Beispiel #20
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);
            }