RPC method not found on obeject?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
RPC method not found on obeject?
Taco
2022-07-16 07:08:07
I am trying to add synchronization and visibility to the bullets my two players are shooting and for some reason, I am getting the error "RPC method 'Shoot()' not found on object with PhotonView 2001. Implement as non-static. Apply [PunRPC]. Components on children are not found. Return type must be void or IEnumerator (if you enable RunRpcCoroutines). RPCs are a one-way message."
My code seems to be correct, I do not have a photonView script on my bullet prefab only the player so I am a bit confused as to why this is occuring.
My code:
// Update is called once per frame
void Update()
{
PlayerShoot();
PlayerMove();
}
void PlayerShoot()
{
if (Input.GetButton("Fire1") && coolingDown.coolingDown == false)
{
photonView.RPC("Shoot", RpcTarget.All, null);
//Shoot();
}
}
[PunRPC] void Shoot()
{
if(Time.time - lastShot < shootSpeed)
{
return;
}
lastShot = Time.time;
Rigidbody clone;
clone = Instantiate(projectile, lwattackPoint.position, transform.rotation * Quaternion.Euler (90f, 0f, 0f));
clone = Instantiate(projectile, rwattackPoint.position, transform.rotation * Quaternion.Euler (90f, 0f, 0f));
}
Comments
Check which object the photonView
points at. It is maybe an object that doesn't have the Shoot method.