Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Mewada-Neil · Mar 14, 2015 at 02:18 AM · networkingnetworkview

A question regarding networking...

I have a question regarding the following script:- (FPS Game Script) I want to find an object named player which are many in a multiplayer game. So the question is, If i use networkView.isMine boolean (bool) , the game will find only that player object which is played by one player, and if I want to destroy only the body of the player who dies, only it will be destroyed or others will also be destroyed???

 using UnityEngine;
 using System.Collections;
 
 public class NetworkingScript : MonoBehaviour
 {
     
 
     void Start ()
     {
 
     }
 
     void Update ()
     {
         if (networkView.isMine)
         {
             if (GameObject.Find("Player"))
             {
                 Destroy(GameObject.Find("Player"));
                 Destroy(gameObject);
             }
         }
     }
 }
 

Thanks in advance...

Comment
Add comment · Show 3
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
avatar image Beennn · Mar 14, 2015 at 05:31 AM 1
Share

I'm not really sure what you're asking, could you rephrase it?

avatar image Mewada-Neil · Mar 14, 2015 at 03:53 PM 0
Share

For example: If three players are playing in a multiplayer game, and all of them have tags named "Player". Let those players have name 'A', 'B' and 'C'.

Now if Player A's Destroy(GameObject.FindGameObjectWithTag("Player")) command is executed using networkView.is$$anonymous$$ine condition, so will it only search and give the reference to it own body or it will return reference for others also???

avatar image YoungDeveloper · Mar 14, 2015 at 04:04 PM 0
Share

You should research and understand the philosophy of online games first.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Lilbob · Mar 14, 2015 at 04:41 PM

You want to use Network.Destroy(NetworkViewID);

The issue with using GameObject.Find("Player") though, is that if your objects are network instantiated, then it will find all players in the scene. Your best bet is using NetworkView.Find(NetworkViewID), OR put a tag on the players, FindObjectsWithTag("Player"), then iterate through them to see which NetworkView is owned by you.

Cheers

Comment
Add comment · Share
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
avatar image
0

Answer by el-pepi · Mar 14, 2015 at 03:46 PM

I belive you are looking for something like this: http://docs.unity3d.com/ScriptReference/Network.Destroy.html

Comment
Add comment · Share
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
avatar image
0

Answer by One Ring · Mar 14, 2015 at 11:29 AM

I don't think that script will have the intended effect, you are checking whether something isMine before you are finding the player, but I'm not positive what you are trying to achieve, if you want to destroy the player controlled by the client that that script is being run on, then find all of the players and for each of them check their isMine, and if its true, then destroy them.

Comment
Add comment · Share
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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiplayer Flashlight Issue 1 Answer

Unity RPC mismatch 0 Answers

How to sync position only one time, using Photon Networking 1 Answer

Overloading RPCs 1 Answer

Networking trouble 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