コード例 #1
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            leftWrist  = GameObject.FindGameObjectWithTag("wristLeft").transform;
            rightWrist = GameObject.FindGameObjectWithTag("wristRight").transform;

            holdingLeft  = leftWrist.GetComponent <HoldingScript>();
            holdingRight = rightWrist.GetComponent <HoldingScript>();

            leftTarget  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightTarget = GameObject.FindGameObjectWithTag("rightTarget").transform;


            chef       = GameObject.FindGameObjectWithTag("chef");
            chefScript = chef.GetComponent <ChefScript>();

            leftIsHolding  = false;
            rightIsHolding = false;

            StartCoroutine(CheckBothHolding());
        }
        if (IsClient)
        {
            yield return(new WaitForSeconds(MyCore.MasterTimer * 5f));

            leftTarget  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightTarget = GameObject.FindGameObjectWithTag("rightTarget").transform;


            chef       = GameObject.FindGameObjectWithTag("chef");
            chefScript = chef.GetComponent <ChefScript>();
        }
        //while (IsServer)
        //{
        //gripDistSqr = gripDist * gripDist;

        /*
         * if ((leftWrist.position - leftGrip.position).sqrMagnitude < gripDistSqr && holdingLeft.isHolding)
         * {
         *  Debug.DrawLine(leftGrip.position, leftWrist.position, Color.green);
         * }
         * if ((rightWrist.position - rightGrip.position).sqrMagnitude < gripDistSqr && holdingRight.isHolding)
         * {
         *  Debug.DrawLine(rightGrip.position, rightWrist.position, Color.green);
         * }
         *
         * bothHolding = ((leftWrist.position - leftGrip.position).sqrMagnitude < gripDistSqr && holdingLeft.isHolding) &&
         *              ((rightWrist.position - rightGrip.position).sqrMagnitude < gripDistSqr && holdingRight.isHolding);
         */
        //SendUpdate("D", bothHolding.ToString());

        //if (bothHolding)
        //  this.transform.position = (leftWrist.position + rightWrist.position) * 0.5f;

        yield return(new WaitForSeconds(MyCore.MasterTimer));    //potentially slower
        //}
    }
コード例 #2
0
ファイル: HandScript.cs プロジェクト: SirBbarnes/GameFinal2
    void Start()
    {
        //targetTransform = target.transform;
        cam = Camera.main;
        StartCoroutine(MoveTarget());

        leftWrist    = GameObject.FindGameObjectWithTag("leftWrist");
        leftHolding  = leftWrist.GetComponent <HoldingScript>();
        rightWrist   = GameObject.FindGameObjectWithTag("rightWrist");
        rightHolding = rightWrist.GetComponent <HoldingScript>();

        mask = LayerMask.GetMask("Kitchen");

        //distanceToMaintain = (originalAxis - rightFoot.position).magnitude;

        //maxDistSqrd = maxDist * maxDist;
    }
コード例 #3
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            //this.transform.rotation *= Quaternion.Euler(0f, -90f, 0f);

            leftChefTransform  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightChefTransform = GameObject.FindGameObjectWithTag("rightTarget").transform;

            fabricLeft         = leftFinger.GetComponent <FastIKFabric>();
            fabricLeft.Target  = leftChefTransform;
            fabricRight        = rightFinger.GetComponent <FastIKFabric>();
            fabricRight.Target = rightChefTransform;

            SendUpdate("HAND", "X");


            //leftWrist = GameObject.FindGameObjectWithTag("wristLeft").transform;
            //leftWrist.SetParent(leftForearm,false);
            //leftForearm.GetChild(0).transform.SetParent(leftWrist);


            //rightWrist = GameObject.FindGameObjectWithTag("wristRight").transform;
            //rightWrist.SetParent(rightForearm,false);
            //rightForearm.GetChild(0).transform.SetParent(rightWrist);


            //SendUpdate("WRIST", "X");

            leftChefTransform.position  = cameraTargetL.position;
            rightChefTransform.position = cameraTargetL.position;

            SendUpdate("SETHAND", cameraTargetL.position.ToString("F3"));

            holdingLeft  = wristLeft.GetComponent <HoldingScript>();
            holdingRight = wristRight.GetComponent <HoldingScript>();

            holdingLeft.onServer  = true;
            holdingRight.onServer = true;
        }
        if (IsClient)
        {
            yield return(new WaitForSeconds(MyCore.MasterTimer * 10));

            this.transform.rotation *= Quaternion.Euler(0f, -90f, 0f);

            leftChefTransform  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightChefTransform = GameObject.FindGameObjectWithTag("rightTarget").transform;

            fabricLeft         = leftFinger.GetComponent <FastIKFabric>();
            fabricLeft.Target  = leftChefTransform;
            fabricRight        = rightFinger.GetComponent <FastIKFabric>();
            fabricRight.Target = rightChefTransform;


            holdingLeft  = wristLeft.GetComponent <HoldingScript>();
            holdingRight = wristRight.GetComponent <HoldingScript>();
        }
        //while (IsServer) //sphere collider equal srist position
        //{
        //if(holdingLeft.currentItem != null)
        //    Debug.Log(holdingLeft.currentItem.name);

        yield return(new WaitForSeconds(MyCore.MasterTimer));    //potentially slower
        //}
    }