How to fix this rpc
Hey guys i get this message Does some one know how to get this working?
--------
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);
}
}
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
@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
Either:
pv.RPC("AddjustCurrentHealth", RPC$$anonymous$$ode.All, curHealth);
or
[PunRPC]
public void AddjustCurrentHealth(int adj, float damage)
@hexagonius did you meen like this?
Answer by Wesley21spelde · Jan 16, 2016 at 04:07 PM
@hexagonius
Did You meen like this?
becouse i get this message
[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);
}
$$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
Follow this Question
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