首页 > 解决方案 > 如何在 Unity 中更改其他玩家的相机?

问题描述

我正在使用带有 Photon 的 Unity3D,我需要模糊另一个玩家的相机。

有谁知道我该怎么做?

标签: c#unity3dphoton

解决方案


将 PhotonView 脚本添加到相机对象和模糊相机对象的脚本。然后在下面创建脚本并将其添加到相机对象中按空格键为对手创建相机模糊效果。

public class PunCamera : MonoBehaviour
{

    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space)) 
        {
            OtherPlayerBlur();
        }
    }
    public void OtherPlayerBlur()
    {
        //Get the PhotonView in the camera object and call the RPC
        var _photonView = this.GetComponent<PhotonView>();
        _photonView.RPC("PunCameraBlur", PhotonTarget.Others);
    }

    [PunRPC]
    private void PunCameraBlur()
    {
        // Camera Blur Method Call
    }
}

推荐阅读