Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Oct 05, 2015 at 10:08 AM by McPluffel for the following reason:

Found it out on my own

avatar image
0
Question by McPluffel · Sep 29, 2015 at 09:13 AM · networkingrespawning

Unity UNET Respawning Player with a new prefab

Some background on what I am trying to do: I am making a zombie mode for my game, where you are trying to hold off wave after wave with AI Zombies and player controlled zombies. If you die as a survivor, you are supposed to be respawned as a Zombie.

Here is my code:

     [SerializeField] GameObject playerPrefab;
 
     GameObject respawnButton;
 
     void Start() {
         if (isLocalPlayer) {
             respawnButton = GameObject.Find("GameManager").GetComponent<GameManager_References>().respawnButton;
             respawnButton.GetComponent<Button>().onClick.AddListener(Respawn);
         }
     }
 
     [Client]
     public void Respawn() {
         if (isLocalPlayer) {
             CmdRespawn();//this.gameObject.GetComponent<NetworkIdentity>().netId, this.playerControllerId);
         }
     }
     
     [Command]
     public void CmdRespawn() {//NetworkInstanceId playerNetId, short id) {
         NetworkServer.Spawn(playerPrefab);
         NetworkServer.ReplacePlayerForConnection(connectionToClient, playerPrefab, playerControllerId);
 }

So, to the problem that I am encountering is that the respawn is triggered for EVERYONE, not only the client that called it. I have searched for this a long time now, and still no answers.

Thanks in advanced.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity Photon help! Transform.position (I'm struggling for days with this) 0 Answers

Unity networking tutorial? 6 Answers

Algorithm to choose optimal spawn position 2 Answers

How to watch in client applications what it is happening in the server one? 0 Answers

Camera switches player in network game 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges