コード例 #1
0
    public void InitTransform(Transform bird, Vector3 velocityAtTransformation)
    {
        transform.position = new Vector3(bird.position.x, bird.position.y + 0.3f, bird.position.z);
        Vector3 crowRotation = bird.localEulerAngles;

        m_CameraHorisontalAngle    = crowRotation.y;
        transform.localEulerAngles = new Vector3(0, m_CameraHorisontalAngle, 0);
        // fixing weird issue with vertical rotation where it went above 90 and the camera clamp would break the desired rotation:
        // see UpdateCameraRotation for further explanation
        m_CameraVerticalAngle = MyGameUtils.LimitVectorAngleTo90(crowRotation.x);

        // force crouch, so that it isn't standing up in a cramped space when reverting to human form
        if (!m_PlayerController)
        {
            m_PlayerController = player.GetComponent <PlayerCharacterController> ();
        }
        m_PlayerController.SetCrouchingState(true, true);

        birdCamMaster = transform.parent.gameObject;
        birdCamMaster.SetActive(true);
        player.SetActive(false);

        characterVelocity = velocityAtTransformation;
        timeRemaining     = possessDuration;
        Invoke("_timerCount", 1f);

        UpdateSpawnPoints();
    }
コード例 #2
0
    public void TransformTo(Vector3 targetPos, Vector3 targetRotation, Vector3 targetVelocity)
    {
        // convert to bird position
        transform.position = new Vector3(targetPos.x, targetPos.y - capsuleHeightCrouching, targetPos.z);
        StartCoroutine(AttemptToStandForXSeconds(1f));

        // convert to bird rotation
        transform.localEulerAngles = new Vector3(0, targetRotation.y, 0);
        // fixing weird issue with vertical rotation where it went above 90 and the camera clamp would break the desired rotation:
        m_CameraVerticalAngle = MyGameUtils.LimitVectorAngleTo90(targetRotation.x);
        playerCamera.transform.localEulerAngles = new Vector3(m_CameraVerticalAngle, 0, 0);

        // convert to bird velocity
        m_WalkController.characterVelocity += targetVelocity * 1.1f;
    }