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 /
avatar image
0
Question by geotsak · Sep 12, 2015 at 06:00 PM · c#unity5photon

PhotonView with id has no method marked with PunRPC

I have this code to send info:

 using UnityEngine;
 using System.Collections;
 
 public class SendAttackInfo : MonoBehaviour {
     public int damage = 100;
     // Use this for initialization
     void Start () {
     
     }
     
     void Update () {
         
         bool RMB = Input.GetMouseButtonDown (1);
         
         if (RMB) {
             
             RaycastHit hit;
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             //&& hit.transform.tag == "Player" && hit.collider.name != this.gameObject.name
             if (Physics.Raycast(ray, out hit)){
                 //float dist = Vector3.Distance(hit.transform.position, this.transform.position);
                 //if(dist <= 2.0f) {
                 PhotonView pv = PhotonView.Get(this);
                 if (pv.isMine) {
                 hit.collider.gameObject.GetComponent<PhotonView>().RPC("ApplyDamage", PhotonTargets.All);
                 }
             }
                 //}
             
         }
         
     }
 }

And this to recieve:

 [PunRPC]
 void ApplyDamage(){
     curHealth -= 50;
     Debug.Log("hit player " + curHealth);
 }

When I try them I get this error:

PhotonView with ID 1002 has no method "ApplyDamage" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args:

Please help!

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 tobiass · Sep 15, 2015 at 04:24 PM

The ApplyDamage method has to be in a script that's on the same GO as the PhotonView. This is maybe not the case?

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 alarm656 · May 21, 2016 at 06:38 PM 0
Share

I can't add PhotonView to each object or is it ok to having too many objects which has PhotonView component?

I have empty Building gameObject. In it I have 3 child objects. $$anonymous$$y empty Building has PhotonView component. I'm instantiating Building object like this:

  GameObject Building1 = (GameObject)PhotonNetwork.InstantiateSceneObject ("Building1", gameObject.transform.position, Quaternion.identity, 0, null);

how can I sync destruction of child objects.

I made like this but I'm having same error.

 void OnCollisionEnter (Collision col)
     {
         if (col.gameObject.tag == "Bullet") 
         {
             hitPoints = hitPoints - BulletScript.damage;
             if (hitPoints <= 0) 
             {
                 GetComponentInParent<PhotonView> ().RPC ("DestroyColone", PhotonTargets.All, hitPoints);
             }
         }
     }
 
     [PunRPC] 
     void DestroyColone ()
     {
 
             Instantiate (broken, transform.position, transform.rotation);
             Instantiate (dustFX, transform.position, transform.rotation);
             Destroy (this.gameObject);
     }




avatar image
0

Answer by yigites · Dec 12, 2015 at 04:46 AM

@geotsak, @tobiass is right and addition to this , I had the same issue. When you made any changes in RPC functions in your code or made changes in your prefab , you have to drag your prefab to scene and press apply in inspector, than you can delete it from scene. It resolves this error every time for me.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Destroying entire parent object on one client but on the other destroying just the child. 1 Answer

How to make script work for all players Unity Photon? 1 Answer

Unity Collision Doesn't Work when Two Players Instantiated 1 Answer

Instantiating scene objects in Photon Multiplayer. 0 Answers

Why do other players have stuttering / laggy movement in Photon? 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