[英]Unity networking, make player disappear for all clients
我需要讓玩家上車時消失。 現在,它可以作為單人游戲使用,但是由於我不熟悉“ Unet”,所以我真的不知道如何實現這一目標,因此我嘗試了一些方法,但是它們沒有用。 這是腳本:
[Client]
void OnControllerColliderHit(ControllerColliderHit hit)
{
//so if we hit car
if(hit.collider.tag == "Vehicle")
{
//if we pressed "E"
if (Input.GetKeyDown(KeyCode.E))
{
//call method to disable some stuff taht should be disabled, like: controller, shoot, weapons etc.
if (isServer)
CmdCall(inVehicle, hit);
else
RpcCall(inVehicle, hit);
}
}
}
[Command]
void CmdCall(bool invehicle, ControllerColliderHit hit){
RpcCall(inVehicle, hit);
}
[ClientRpc]
void RpcCall(bool invehicle, ControllerColliderHit hit)
{
disable(inVehicle, hit);
}
我在控制台中看不到任何錯誤,但是我無法進入播放模式,原因是存在一些編譯器錯誤,再次在控制台中看不到。 感謝您的任何提示,評論,贊,贊成或暗示:)
嘗試使用NetworkServer.UnSpawn ()
和NetworkServer.Spawn ()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.