[英]Unity networking, make player disappear for all clients
I need to make the player disappear when he gets in car. 我需要让玩家上车时消失。 Right now, it works as a single-player, but since I am new to "Unet" I don't really know how to achieve this, I tried some ways, but they didn't work. 现在,它可以作为单人游戏使用,但是由于我不熟悉“ Unet”,所以我真的不知道如何实现这一目标,因此我尝试了一些方法,但是它们没有用。 Here is script: 这是脚本:
[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);
}
I can't see any errors in console but I cant enter play mode cause there are some compiler errors, which again i cant see in console. 我在控制台中看不到任何错误,但是我无法进入播放模式,原因是存在一些编译器错误,再次在控制台中看不到。 thank you for any tip, comment, downvote, upvote, or hint :) 感谢您的任何提示,评论,赞,赞成或暗示:)
尝试使用NetworkServer.UnSpawn ()
和NetworkServer.Spawn ()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.