Question by 
               Wesley21spelde · Jan 15, 2021 at 04:26 PM · 
                collisionnot workingrpc  
              
 
              rpc Call problem dont know how to fix this
can someone tell me what i did wrong? i know the problem is here
 h.GetComponent<PhotonView>().RPC("TakeDamage", PhotonTargets.All, weaponData.damage);
 
               i got this message
 NullReferenceException: Object reference not set to an instance of an object
 Granate_Explode.OnCollisionEnter (UnityEngine.Collision collision) (at Assets/Scripts/C++_Multiplayer/Granate_Explode.cs:30)
 
               when i shoot it at a building nothing hapens like it should but when i hit a object taged Enemy i get this. using System.Collections; using System.Collections.Generic; using UnityEngine;
 public class Granate_Explode : MonoBehaviour
 {
     WeaponData weaponData;
 
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     private void OnCollisionEnter(Collision collision)
     {
         if (collision.transform.tag == "Enemy")
         {
             PhotonView pv = collision.transform.GetComponent<PhotonView>();
             if (pv == null)
             {
                 Debug.LogError("No PhotonView On Object!");
             }
             else
             {
 
                 weaponData = gameObject.GetComponentInChildren<WeaponData>();
                 Health h = collision.transform.gameObject.GetComponent<Health>();
 
                 h.GetComponent<PhotonView>().RPC("TakeDamage", PhotonTargets.All, weaponData.damage);
             }
         }
     }
 
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Why isn't my pistol colliding with the wall? 1 Answer
The requested feature is not implemented. 0 Answers
Detecting Collision is not working 1 Answer
how disable/enable rigidbody and box collider 1 Answer
rpc not working 0 Answers