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 awdawdawd · Jul 05, 2012 at 04:01 PM · multiplayernetworkviewid

MultiPlayer - NetworkPlayer Event

Hello,

I'm working on the bits of my network game of when someone quits or leaves. Basically, the game is a 'capture the flag' type game, and I want to call a function when the player has the flag, and then quits... So the flag is 'dropped', instead of being destroyed with the player.

The function is attached to the actual character, and I'm struggling to talk to it.

So, when someone leaves, this function is called:

 function OnPlayerDisconnected (player : NetworkPlayer){

This is on a game object on my root. I need to somehow use the 'player' as a reference to find the 'character' to then call the function attached to him.

The function is an RPC and is called DropFlag, and is on a script called 'HealthSystem', and is attached to my character:

 networkView.RPC("DropFlag", RPCMode.AllBuffered, player.viewID);

So, what I really need to do is something like this:

 var character = player.FindObject("Player");
 var health = character.GetComponent(HealthSystem);
 health.networkView.RPC("DropFlag", RPCMode.AllBuffered, player.viewID);

This 'DropFlag' works, its also called when you kill the player with the flag... He drops it, and spawns somewhere else, without the flag.

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 ThePunisher · Jul 05, 2012 at 04:32 PM 0
Share

Not sure I understood you properly. You're saying that it works fine when the player is killed but not when the player disconnects? It could be that the game object/component has already been destroyed? Could you try calling it from the OnDestroy if the player has the flag?

avatar image Swift_On_Fire · Jul 05, 2012 at 04:36 PM 0
Share

I second ThePunisher. At some point, if the game object is getting destroyed, then at some point OnDestroy will get called. That will make sure 'DropFlag' gets called.

ThePunisher, why didn't you put that in an answer?

avatar image ThePunisher · Jul 05, 2012 at 04:42 PM 0
Share

:( I shall do that

2 Replies

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

Answer by ThePunisher · Jul 05, 2012 at 04:43 PM

It could be that the game object/component has already been destroyed? Could you try calling it from the OnDestroy if the player has the flag?

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 nventimiglia · Jul 05, 2012 at 05:34 PM

OnPlayerDisconnected is only handled on the host.

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

8 People are following this question.

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

Related Questions

Get the ID/name of the player that joined the game. 1 Answer

Network Instantiate with wrong owner. 2 Answers

help on synchronizing newtorked views... 0 Answers

Sending info to/from different networkViews 1 Answer

Multiplayer Animating 2 Answers


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