CameraMove.Update C# (CSharp) Метод

Update() публичный Метод

public Update ( ) : void
Результат void
    void Update()
    {
        if (!Target)
            return;

        // Calculate the current rotation angles
        var wantedRotationAngle = Target.eulerAngles.y;
        var wantedHeight = Target.position.y + Height;

        var currentRotationAngle = transform.eulerAngles.y;
        var currentHeight = transform.position.y;

        // Damp the rotation around the y-axis
        currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, RotationDamping * Time.deltaTime);

        // Damp the height
        currentHeight = Mathf.Lerp (currentHeight, wantedHeight, HeightDamping * Time.deltaTime);

        // Convert the angle into a rotation
        var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);

        // Set the position of the camera on the x-z plane to:
        // distance meters behind the target
        transform.position = Target.position;
        transform.position -= currentRotation * Vector3.forward * Distance;

        _pos = transform.position;
        _pos.y = currentHeight;
        // Set the height of the camera
        transform.position = _pos;

        // Always look at the target
        transform.LookAt (Target);
    }

Usage Example

Пример #1
0
    //===============================================================================
    // 毎フレーム更新
    //===============================================================================
    void Update()
    {
        //--------------------------------------------------------
        //// CameraAttentionのサンプル
        //if(Input.GetKeyDown(KeyCode.T)){
        //    flg = !flg;
        //    if(flg){
        //        kariRange = range;
        //        kariAdjust = adjust;
        //        range = 2;
        //    }
        //    else{
        //        range = kariRange;
        //        adjust = kariAdjust;
        //    }
        //}
        //if(flg){
        //    adjust = cameraPos + forwardMove;
        //}

        cameraMove.Update();
        cameraAttention.Update();

        //if(Input.GetKeyDown(KeyCode.Y) ){
        //    string str = "あいうえお!!!あいうえお!!!あいうえお!!!あいうえお!!!あいうえお!!!";
        //    MessageManager.Instance.Create(str, "Iphone", 32);
        //}
    }
All Usage Examples Of CameraMove::Update
CameraMove