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 KuPAfoo · Feb 09, 2014 at 07:33 AM · guiphotondeadkill player

[Photon]Player dies when new player connects

Okay... I'm going to try and make this as painless as possible. I wrote all this code myself. I'm comparing two meshes in a collision elsewhere. The compared collisions are between a weapon and a player's body.

The code below is commented hopefully as much as possible. Here's the issue as a scenario. Player 1 kills player 2. Player 2 posts to player 1 & 2's GUI that player 1 has 1 kill. The player can continue gaining kills over and over. When a new player connects, player 2 posts to player 3 the GUI score for player 1. If player 2 was the only one who died, player 2 dies as player 3 connects. [b] Why does he die?[/b]

A side note, when the player who died disconnects from the server, the scores are erased and put back to nothing. When a new player connects, the GUI stops updating.

 private void OnGUI () {
     
         if(lastID>11000)
         if(GUI.Button (new Rect (0, (lastID/1000)*40, 150, 20), "Last Kill by: "+lastID)  && myPhotonView.viewID == lastID){
                 if(this.hpWidth<8.0f && winnerID==myPhotonView.viewID)
                 hpWidth+=1.0f;
             }//if more than 10 players have connected, display in correct place
         if(lastID!=0 && GUI.Button (new Rect (Screen.width-150, (lastID/1000)*40, 150, 20), "viewID "+lastID+" has ["+kC[lastID]+"] kills")){
                 if(this.hpWidth<8.0f && lastID==myPhotonView.viewID)//if i'm not dead and I won last
                 this.hpWidth+=1.0f;//heal a little
             }//show gui for winner's kill count
     if(myPhotonView.isMine){//if i'm looking at the game
             if(this.hpWidth<=0.0f){//if i'm also dead
                 calcDeath (hasDIED);//find out who killed me
                 
                 hasDIED=true;//tell game i've calculated who killed me
             
         if (GUI.Button (new Rect (10,10,150,100), "Respawn")) {//show a button for respawning                    
             this.myPhotonView.RPC("spawnHP", PhotonTargets.AllBuffered);//update HP for spawn HP
             hpWidth=8.0f;//update hp in case spawnHP didn't work
             this.myPhotonView.RPC("updateHP", PhotonTargets.AllBuffered, hpWidth);    
                 check=0;
                     newestID=0;
                     if(hasDIED==true){
             this.myPhotonView.RPC("sendlast", PhotonTargets.AllBuffered, winnerID);
                 }//sending the winner's viewID to all players, adds score+=1
                     hasDIED=false;
                 
                 }        
             }//isDead
         }//ismine
     }

Of course there's more code, If nobody posts I'll just add more blocks of the code. If you have any ideas, answers would be nice so we can keep code blocks in the original question's comments section. Thanks for any assistance!

Comment
Add comment · Show 2
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 KuPAfoo · Feb 09, 2014 at 09:14 AM 0
Share

Ok... if the player is damaged, but not dead (anything but full hp) and a new player connects, the player who has died previously instantly dies on new connection.

Here's some more code...

 [RPC]
     private void sendlast(int thiswinner){
         ownLog[winnerID]=0;
         lastID = thiswinner;    
             kC[lastID]+=1;
         if(kC[lastID]>4 && myPhotonView.viewID == lastID)
             swordW.particleSystem.enableEmission = true;
     }
         
     [RPC]
     private void spawnHP(float hpWidth){
             hpWidth = 8.0f;
             player.renderer.enabled = true;//found
             swordW.renderer.enabled = true;//found
             sheildW.renderer.enabled = true;//found
             swordW.collider.enabled = true;//found
             this.rigidbody.collider.enabled = true;//found
             swordW.rigidbody.collider.enabled = true;//found
         if(kC[lastID]>4 && myPhotonView.viewID == lastID)
             swordW.particleSystem.enableEmission = true;
             //swordW.particleSystem.renderer.enabled = true;//found
         
     }
avatar image KuPAfoo · Feb 10, 2014 at 03:13 AM 0
Share

The GUI isn't so much the issue here atm... I'm more concerned with the player connecting and killing another player immediately. The winnerID = viewID (2) rather than viewID 1001+.

so, it dies due to something the player connects with, but the player never touches the fragile player

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

[Photon] collider's owner's myphotonview? 0 Answers

whoHit me most? Photon 0 Answers

Access Var From Another GameObject 1 Answer

Button Turns Off and On Object 1 Answer

Finish rotation in the same angle of beginning? 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