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 Jeredriq · Apr 20, 2015 at 02:38 PM · gameobjectdestroyphoton

Photon Network Cant Destroy Game Object In All Clients

Header explains itself. I need help please. Any help would be appriciated.

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 Crystalline · Apr 20, 2015 at 02:39 PM 0
Share

$$anonymous$$ore info needed..

avatar image Jeredriq · Apr 21, 2015 at 09:39 AM 0
Share

I dont know how to destroy objects on Photon Network

avatar image AlucardJay · Apr 24, 2015 at 05:01 AM 0
Share

http://doc-api.exitgames.com/en/pun/current/pun/doc/class_photon_network.html#a52fdada993f0729be0912113c0ddb3f8

http://doc-api.exitgames.com/en/pun/current/pun/doc/class_photon_network.html

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Laran · Apr 21, 2015 at 12:36 PM

Function that You use to destroy game object must be marked as an RPC before it can be invoked remotely.

For example:

 void myFunction() {
     //code...
 }

should be:

C#

 [RPC]
 void myFunction() {
     //code...
 }

JS

 @RPC
 function myFunction() {
     //code...
 }

Following code invokes an RPC function:

 networkView.RPC ("myFunction", RPCMode.AllBuffered);

If You have to pass variables to the function, just type it after RPC.Mode.AllBuffered and comma. For example:

 networkView.RPC ("myFunction", RPCMode.AllBuffered, myVariable);


You can read more about RPC here: http://docs.unity3d.com/Manual/net-RPCDetails.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 Laran · Apr 21, 2015 at 10:08 AM

C#

 //function used to destroy game object
 [RPC]
 void networkDestroy(GameObject gO) {
     Destroy(gO);
 }
  
 // calling the RPC
 photonView.RPC("networkDestroy", PhotonTargets.All, objectToDestroy);

Here are some basic information about networking using Photon: http://doc.exitgames.com/th/pun/current/getting-started/pun-intro

I used PhotonTargets.All to send this information to all (clients and server), but You can specify who will receive this RPC. You can read more about this here: Photon Documentation

Comment
Add comment · Show 1 · 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 InfernoZYB · Apr 24, 2015 at 03:46 AM 0
Share

Sadly this does not work as you cant sent GameObjects over RPC's. You would need to send the ViewID then extract the gameobject from that.

avatar image
0

Answer by Jeredriq · May 19, 2015 at 05:01 PM

I've got this code:

 public void OnTriggerEnter(Collider col){
 
         if(col.gameObject.tag=="Knife")
 photonView.RPC("networkDestroy", PhotonTargets.All, transform.parent.gameObject);
 }
 
 [RPC]
     public void Die(GameObject parent)
     {    Destroy (parent);
 
     }

but it seems to doesnt work. It gives me this error

Exception: cannot serialize(): UnityEngine.GameObject ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)

Comment
Add comment · Show 1 · 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 InfernoZYB · Jul 16, 2015 at 03:26 AM 0
Share

You cannot send a gameobject over the network.

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

22 People are following this question.

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

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

How to Destroy Game Object In All Clients in Photon Network 0 Answers

Photon Network Cant Destroy Player Objects 1 Answer

How to detect if a GameObject has been destroyed? 3 Answers

Destroy a game object if score = 1000 ? 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