Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Wesley21spelde · Jan 16, 2016 at 12:09 PM · scripting problembulletrpc

How to fix this rpc

     Hey guys i get this message Does some one know how to get this working?

 
 

alt text

 --------
 Bullet schript
 
 using UnityEngine;
 using System.Collections;
 
 public class Bullet3 : MonoBehaviour
 {
     public float curHealth = 10.0f;
     public int maxHealth = 100;
 
 
 
     [PunRPC]
     void OnCollisionEnter(Collision col)
     {
         if (col.transform.tag == "Enemy")
         {
             var pv = GetComponent<PhotonView>();
             if (pv == null)
             {
                 Debug.LogError("Freak Out!");
             }
             else
             {
                 pv.RPC("AddjustCurrentHealth", RPCMode.All, curHealth, 10.0f);
             }
         }
     }
 }
 -----------
 Enemy Health schript
 
 using UnityEngine;
 using System.Collections;
 using System;
 
 public class EnemyHealth : MonoBehaviour
 {
     public int maxHealth = 100;
     public int curHealth = 100;
     public float damage = 10.0f;
 
     void Start()
     {
         //dh = GameObject.Find("HealthBar").GetComponent<DisplayHealth>();
     }
 
     void OnGUI()
     {
         // GUI.Box(new Rect(10, 40, healthBarLength, 20), curHealth + "/" + maxHealth);
     }
 
 [PunRPC]
     public void AddjustCurrentHealth(int adj)
     {
         curHealth += adj;
 
         if (curHealth < 0)
             curHealth = 0;
 
         if (curHealth > maxHealth)
             curHealth = maxHealth;
 
         if (maxHealth < 1)
             maxHealth = 1;
 
         if (curHealth < 10)
             Die();
 
        // healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
     }
 
     [PunRPC]
     void Die()
     {
         //GetComponent<NetworkView>().RPC("Die", RPCMode.All,null);
         PhotonView.Destroy(gameObject);
     }
 }


rpc-fail.jpg (189.0 kB)
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Jan 16, 2016 at 01:08 PM

You're calling

 pv.RPC("AddjustCurrentHealth", RPCMode.All, curHealth, 10.0f);

but it's declared as

  [PunRPC]
      public void AddjustCurrentHealth(int adj)

match the parameters

Comment
Add comment · Show 3 · 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 Wesley21spelde · Jan 16, 2016 at 03:12 PM 0
Share

@hexagonius Can you please help me i cant get it to work can you please fix it for me so i can see what i did wrong i hope you will help me thanks

avatar image hexagonius Wesley21spelde · Jan 16, 2016 at 03:15 PM 0
Share

Either:

 pv.RPC("AddjustCurrentHealth", RPC$$anonymous$$ode.All, curHealth);

or

   [PunRPC]
       public void AddjustCurrentHealth(int adj, float damage)

avatar image Wesley21spelde Wesley21spelde · Jan 16, 2016 at 06:25 PM 0
Share

@hexagonius did you meen like this?

avatar image
0

Answer by Wesley21spelde · Jan 16, 2016 at 04:07 PM

 @hexagonius


 Did You meen like this?

becouse i get this message


alt text

    [PunRPC]
     public void AddjustCurrentHealth(int adj, float curHealth)
     {
         curHealth += adj;
 
         if (curHealth < 0)
             curHealth = 0;
 
         if (curHealth > maxHealth)
             curHealth = maxHealth;
 
         if (maxHealth < 1)
             maxHealth = 1;
 
         if (curHealth < 10)
             PhotonView.Destroy(gameObject);
 
         // healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
     }




errorlog.jpg (49.0 kB)
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 hexagonius · Jan 17, 2016 at 05:57 PM 0
Share

$$anonymous$$aybe check this out. It's photon, don't they have a forum too?

http://answers.unity3d.com/questions/176060/the-requested-feature-is-not-implemented.html

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

42 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 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

Getting transform of an object to which script wasnt assigned to 0 Answers

Need help for bullet script,Script for bullet 0 Answers

The requested feature is not implemented. 0 Answers

punrpc fails 0 Answers

please Help With RPC CALL 0 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