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 TheMaster42 · Sep 28, 2014 at 07:44 PM · multiplayerdestroynetwork.instantiatenetwork.destroy

Tell if remote Network.Instantiate object still exists

Is there a way to tell if the remote instance of a Network.Instantiate object still exists (or not)? I want to delete a remote instance locally, and then later call Network.Destroy without an error.

I am making a (2D) game where players can shoot bullets at each other. I'm using Network.Instantiate for the bullets so that I can destroy all its remote copies when the creator decides.

For the remote instances, I want the bullets to look like they're behaving normally, but only the creator can destroy the bullet and choose to inflict damage on players. (I understand this is not a secure method, but it's just for a prototype and I hear Unity's networking isn't secure anyway.)

SO! If a remote bullet thinks it hit a player, but the creator doesn't think it's hit yet, I want to destroy the remote instance locally. Later, on the frame the creator thinks the bullet "really" hit, I want to Network.Destroy the bullet. But this throws an error: Couldn't perform remote Network.Destroy because the network view 'AllocatedID: 51' could not be located.

Comment
Add comment · Show 1
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 TheMaster42 · Sep 28, 2014 at 11:26 PM 0
Share

There may very well be no way to do this. If so, what's the "right" implementation to handle this case? I guess I could hide the bullet on the remote side and set its script inactive, and then let it be destroyed when the creator copy says so?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Louis Watson · Sep 28, 2014 at 11:35 PM

well could you use SetActive on the bullet's gameobject to false then your destroy will not throw an error.

Comment
Add comment · Show 2 · 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 TheMaster42 · Sep 30, 2014 at 12:13 AM 0
Share

Actually if the remote object is inactive you get the same error. It's deactivating the networkView as well, I suppose.

avatar image Louis Watson · Sep 30, 2014 at 01:09 PM 0
Share

my bad obviously the NetworkView must be perfor$$anonymous$$g an "Active" or "Enabled" filter when searching for items in the scene.

As a possible solution and without testing any code another option I could see is maybe tracking the ID's rather than the game objects themselves, then in the procedure that performs the Network.Destroy, you could perform a check on that id to see if its active before destroying it.

Alternatively wrapping the bullet in another Game Object could work. Disable the actual bullet when you want, then destroy the wrapper with Network.Destroy.

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

26 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 avatar image avatar image avatar image avatar image

Related Questions

Network.instantiate & RPC destroy 3 Answers

How can I delete or destroy an instance of an object IN A MULTIPLAYER GAME?. 2 Answers

Checking if RPC queue is empty? 0 Answers

How to let the other network player to see a launched rocket and its explosion? 1 Answer

Player not deleting on server exit 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