Skip to main content

As title says iI need to make the player disapepardisappear when he gets in car. rightRight now, it works for singleplayeras a single-player, but since iI am new to unet iI don't really know how to achieve this, iI tried some ways, but they didn't work. 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 :)

--Nick.

As title says i need to make player disapepar when he gets in car. right now, it works for singleplayer, 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. 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 :)

--Nick.

As title says 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. 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 :)

--Nick.

Source Link
Nick
  • 561
  • 5
  • 21

Unity networking, make player disappear for all clients

As title says i need to make player disapepar when he gets in car. right now, it works for singleplayer, 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. 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 :)

--Nick.