Пример #1
0
    //transtions in or out of specified prisoner
    private float transitionP(Prisoner curPrisoner, bool enter)
    {
        float waitTime = 0;

        if (enter)
        {
            //enable third person camera rig and set on target
            prisonerCamera.gameObject.SetActive(true);
            prisonerCamera.gameObject.transform.position = curPrisoner.transform.position;

            //make our camera be set so that it's always looking right behind the player
            prisonerCamera.gameObject.transform.rotation = Quaternion.LookRotation(curPrisoner.gameObject.transform.forward);
            prisonerCamera.LookAngle = prisonerCamera.gameObject.transform.eulerAngles.y;

            //set our current prisoners camera pivot positioning
            Vector3 pivotPosition = prisonerCamera.gameObject.transform.GetChild(0).localPosition;
            pivotPosition.y = curPrisoner.camPivVert;
            pivotPosition.x = curPrisoner.camPivHor;
            //set zoom and pivot
            prisonerCamera.gameObject.transform.GetChild(0).localPosition             = pivotPosition;
            prisonerCamera.gameObject.transform.GetChild(0).GetChild(0).localPosition = new Vector3(0, 0, 0);

            //set our target and enable our animation
            prisonerCamera.SetTarget(curPrisoner.gameObject.transform);
            waitTime            = curPrisoner.bodyTransition(true);
            currentlyPossessing = curPrisoner;
        }
        else
        {
            curPrisoner.stopControlling();
            waitTime            = curPrisoner.bodyTransition(false);
            currentlyPossessing = null;
        }
        return(waitTime);
    }