FPC to tigger shots on each client

I'm very new to all of this, but I've found a lot of answers to my questions on this board already so cheer to all those awesome question answer'ers.

I've got a simple setup right now, spent the day trying to figure out some FPC

I'm trying to get an the same gun to fire on each client, which I've had limited success. I can instantiate it no problem and smooth it out with Lerp but I thought it would be better to have each client fire the cannonball locally.

Any one client works fine, but once there are two then the cannonball don't go anywhere on one client, but the other client it behaves perfectly. This is the only error I get.
[Error] : Tried to run OnPhotonSerializeView, but this method was missing on: Scripts (FireCannon)

Here is the relevant code.

Thanks so much for any help in advance. Can't believe how easy it was for a guy like me to get some of this working so quickly using the Photon plugin.

[code2=csharp]using UnityEngine;
using System.Collections;

public class FireCannon : Photon.MonoBehaviour {

public GameObject bulletType;
public float bulletImpluse;
public Transform launchPoint;
public float Distance;
public bool fire = false;


[RPC]
void fireBullet(float bulletImpluse, Vector3 launchPointP, Vector3 launchPointR, Vector3 launchPointF, float Distance)
{
Debug.Log("CannonFired "+Distance);
GameObject cannonBall = (GameObject)Instantiate(bulletType, launchPointP, Quaternion.Euler(launchPointR));
cannonBall.rigidbody.AddForce(launchPointF * bulletImpluse* Mathf.Sqrt(Distance), ForceMode.Impulse);
//AudioSource.PlayClipAtPoint(cannonShot,transform.position);
}

void Update () {

if(fire == true){
this.photonView.RPC("fireBullet", PhotonTargets.All, bulletImpluse, launchPoint.position, launchPoint.eulerAngles, launchPoint.forward, Distance);
fire = false;
}
}
}[/code2]

the code is triggered from another script

[code2=csharp]gameController = GameObject.Find("masterGun");
gameController.GetComponent<FireCannon>().fire = (bool)fire;[/code2]


I'm sure it's a mess, I'm using this as a good excuse to learn code too.
Chris

Comments

  • > [Error] : Tried to run OnPhotonSerializeView, but this method was missing on: Scripts (FireCannon)
    This looks like you setup the PhotonView to observe the FireCannon script. Any observed script has to implement OnPhotonSerializeView (like in the demos) to work with being observed.

    At the moment you are just using RPCs and you can use them from any script on the same GameObject. You don't have to observe this script, if it shouldn't sync something permanently.