Dext
1
Hi,
I attached this script to a particle System
using UnityEngine;
using System.Collections;
public class particletrigger : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
private void Update () {
if(Input.GetKeyDown(KeyCode.Space))
networkView.RPC("DoExploder",RPCMode.All, new object[]{15});
else if (Input.GetKeyDown(KeyCode.Return)){
networkView.RPC("DoExploder",RPCMode.All, new object[]{15});
}
}
[RPC]
public void DoExploder(int count){
particleSystem.Emit(count);
}
}
but I get this error message when I try to activate the particle system.
Can’t send RPC function since no connection was started.
UnityEngine.NetworkView:RPC(String, RPCMode, Object)
particletrigger:Update() (at Assets/Photon Unity Networking/Resources/NetworkScript/particletrigger.cs:15)
I have attached a photon view on the particle system.
I cant understand why there is no connection since it synchronizes the movement of the player and create rooms. So there must be connection
Here is my Network manager that should establish the connection succesfully
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
SpawnSpot[] spawnspots ;
// Use this for initialization
void Start () {
spawnspots = GameObject.FindObjectsOfType<SpawnSpot>();
// Rufe Funtkion connect auf
Connect();
}
// Update is called once per frame
void Update () {
}
void Connect (){
// Verbindet auf den Server mit der Deklaration der Versionsnummer
PhotonNetwork.ConnectUsingSettings("1.0") ;
}
void OnGUI(){
// Kreire ein Gui Objekt, welches die aktuellen Informationen über unseren Verbindungsstatus enthält
GUILayout.Label ( PhotonNetwork.connectionStateDetailed.ToString() ) ;
}
void OnJoinedLobby () {
PhotonNetwork.JoinRandomRoom() ;
}
void OnPhotonRandomJoinFailed (){
PhotonNetwork.CreateRoom(null);
}
void OnJoinedRoom() {
spawnmyplayer () ;
}
void spawnmyplayer () {
SpawnSpot myspawnspot = spawnspots[Random.Range ( 0, spawnspots.Length)] ;
GameObject myPlayerGO = (GameObject) PhotonNetwork.Instantiate("Player", myspawnspot.transform.position, myspawnspot.transform.rotation,0) ;
myPlayerGO.GetComponent<PlayerMovement>().enabled = true;
myPlayerGO.transform.FindChild("Camera").gameObject.SetActive(true) ;
}
}
I don’t know VERY much about RPC calls in photon, but instead of
networkView.RPC("DoExploder",RPCMode.All
Try:
PhotonView.RPC("DoExploder",PhotonTargets.All