示例#1
0
    // —————
    // ————— Figure out which position to go to next.
    // —————
    void getNextPosition(int _goWhere, string _displayText)
    {
        // print("go Move!" + _goWhere + " " + _displayText);

        // Update State Machine
        currentPosition = _goWhere;
        movementState   = moveHolder.MOVING;

        // ————— Cycle through positions until we found the next one
        if (whereToMoveTo == Vector3.zero)
        {
            foreach (positionScript ps in positions)
            {
                if (_goWhere == ps.id)
                {
                    whereToMoveTo  = ps.transform.position;
                    scriptOfTarget = ps;
                    scriptOfTarget.changeDisplayText(_displayText);
                    break;
                }
            }
            if (whereToMoveTo == Vector3.zero)   // catch error where the id is out of range
            {
                print("Error found!");
                whereToMoveTo = positions[0].transform.position; // go to first position as fallback
            }
        }
        // ————— set next look rotation
        getNextRotationHolder.position = transform.position;
        getNextRotationHolder.rotation = transform.rotation;
        getNextRotationHolder.LookAt(whereToMoveTo);
    }
示例#2
0
    // ————— ————— ————— —————

    void Start()
    {
        // Begin not moving
        movementState = moveHolder.ARRIVED;

        // Grab where to go
        GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("positions");
        foreach (GameObject go in gameObjects)
        {
            // print( positions );
            positions.Add(go.GetComponent <positionScript>());
        }

        // Initial Server Request
        lastTime = Time.time;
        StartCoroutine(getPositionFromServer());
    }
示例#3
0
 // —————
 // ————— If we need to move, use this function to fly to the next position
 // —————
 void moveCamera()
 {
     // print("moving " + whereToMoveTo);
     if (whereToMoveTo != Vector3.zero)
     {
         transform.position = Vector3.Lerp(transform.position, whereToMoveTo, movementSpeed * Time.deltaTime);
         //Quaternion.LookRotation(whereToMoveTo)
         transform.rotation = Quaternion.Lerp(transform.rotation, getNextRotationHolder.rotation, movementSpeed * Time.deltaTime);
         //transform.rotation *= lookWhere;
     }
     // ————— stop if you're close enough
     if (Vector3.Distance(transform.position, whereToMoveTo) < minimumDistance)
     {
         movementState = moveHolder.ARRIVED;
         whereToMoveTo = Vector3.zero;
         scriptOfTarget.startTextFadeIn();
         // print("arrived!");
     }
 }