示例#1
0
    void followSavedTrajectory()
    {
        var point = new Vector3(targetSavingPoint.x, targetSavingPoint.y, targetSavingPoint.z);

        transform.position = Vector3.MoveTowards(transform.position, point, moveSpeed * Time.deltaTime);
        if (transform.position == point)
        {
            currentSavingPoint++;
            targetSavingPoint = Spoints[currentSavingPoint];
        }
    }
示例#2
0
    // Update is called once per frame

/*
 *  void FixedUpdate(){
 *      framecount++;
 *      angles = GetPitchYawRollDeg(Quaternion.LookRotation(head.transform.forward));
 *      angles = new Vector3(angles.x, angles.y, angles.z);
 *      capture = true;
 *      string content ="   {Frame:" + framecount + " Point: " + UnitsToPixels(head.transform.position) + " Pitch: " + angles.x + " Yaw: " + angles.y + " Roll: " + angles.z + "\n";
 *      File.AppendAllText(pathTxt, content);
 *      Debug.Log(content);
 *      capture = false;
 *  }
 */
    void LateUpdate()
    {
        /*
         * //FOLLOW MOUSE
         *  Vector3 mousePos = viewCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, viewCamera.transform.position.y));
         *  transform.LookAt(mousePos + Vector3.up * transform.position.y);
         *  velocity = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized * moveSpeed;
         */

        if (SetUp.followRealTrajectories)
        {
            head.rotation = fixHead;
            //PROVES 477, 569

            TrajectoryPoint point;
            if (dictionary.TryGetValue(477, out point))
            {
                RecreatePoint(point);
            } /*
               * if (currentTrajPoint < points.Length )
               * {
               * if (targetTrajPoint == null) targetTrajPoint = points[currentTrajPoint];
               * followTrajectory();
               * }  */
        }
        else if (repeating)
        {
            //head.rotation = fixHead;
            if (currentSavingPoint < Spoints.Length)
            {
                if (targetSavingPoint == null)
                {
                    targetSavingPoint = Spoints[currentSavingPoint];
                }

                if (fow.closestTarget != null)
                {
                    GetComponent <Animator>().enabled = false;
                    look(fow.closestTarget);
                    focus     = true;
                    focusTime = Random.Range(1f, 4f);
                    StartCoroutine("Wait", focusTime);
                }

                if (!focus)
                {
                    followSavedTrajectory();
                }
            } //if(currentSavingPoint == Spoints.Length) //AppHelper.Quit();
        }
        else
        {
            if (currentWayPoint < this.wayPointsList.Length)
            {
                if (targetWayPoint == null)
                {
                    targetWayPoint = wayPointsList[currentWayPoint];
                }


                if (fow.closestTarget != null)
                {
                    GetComponent <Animator>().enabled = false;
                    look(fow.closestTarget);
                    focus = true;
                    // focusTime = 2f;//Random.Range(1f, 4f);
                    StartCoroutine("Wait", focusTime);
                }

                if (!focus)
                {
                    if (SetUp.randomTrajectory)
                    {
                        WalkRandom();
                    }
                    else
                    {
                        FollowWayPoints();
                    }
                }
            }

            /*
             * if(framecount <=500 ){
             *  SavingPoint aux = new SavingPoint();
             *  aux.frame = framecount;
             *  aux.x = transform.position.x;
             *  aux.y = transform.position.y;
             *  aux.z = transform.position.z;
             *  aux.rotx = transform.forward.x;
             *  aux.roty = transform.forward.y;
             *  aux.rotz = transform.forward.z;
             *  savPoints.Add(aux);
             * }
             * if(framecount == 500){
             *  string TraJson = JsonHelper.ToJson(savPoints.ToArray(),true);
             *  Debug.Log(TraJson);
             *  File.AppendAllText(pathJson, TraJson);
             *  AppHelper.Quit();
             * } */
        }
    }