再看一下
17:16
!
不同之处不在于实例化,而在于实例化对象(预制件)所附加的组件:
MoonController
PlayerController
(玩家使用)
而
卫星控制器
基本上除了注册月球什么都不做:
void Start ()
{
// Register this object to the current game controller.
// This is important so that all clients have a reference to this object.
GameController.Instance.RegisterMoon (this);
}
总是设置为
position
rotation
Update
public Transform CameraTransform;
private void Start ()
{
CameraTransform = FindObjectOfType ().transform;
// Register this player to the GameController.
// Important: all clients must have a reference to this player.
GameController.Instance.RegisterPlayer (this);
// Hide your own model if you are the local client.
if (photonView.isMine)
gameObject.transform.GetChild (0).gameObject.SetActive (false);
}
void Update ()
{
// If this player is not being controlled by the local client
// then do not update its position. Each client is responsible to update
// its own player.
if (!photonView.isMine && PhotonNetwork.connected)
return;
// The player should have the same transform as the camera
gameObject.transform.position = CameraTransform.position;
gameObject.transform.rotation = CameraTransform.rotation;
}
}
因此,在实例化两个对象后的第一帧中,Player对象已经在摄影机的位置和旋转上,而月亮仍然在它的实例化点上
0,0,0