Hello everyone,
Since two days, i’m completely stuck on my problem. I have a mage that have to cast a spell. My code work on the “client/host” side but not on the “client only” side. And if a create a “server only” and connect to it as a “client only” the code doesn’t work too on the “client only” side. Here’s my code, i’m probably missing something…
Here is the code of “FireMageSpellController.cs” (NetworkBehaviour)
void Update()
{
if (Input.GetButtonDown ("Spell1"))
{
InvokeSpell ();
}
if (Input.GetButtonDown ("Fire1"))
{
pAtt.currentMana -= currentSpellCost;
placingSpell = false;
CmdCastSpell ();
}
}
[Command]
public void CmdCastSpell()
{
if (spell_type == SPELL_TYPE.FIRERAIN)
{
animator.SetTrigger ("Attack");
NetworkServer.Spawn (spellTemp);
FM_FireRain fr = spellTemp.GetComponent<FM_FireRain> ();
fr.RpcStartSpell ();
nextFireRainCastTime = Time.time + fr.acd;
}
}
void InvokeSpell()
{
if (!CooldownFireRain ())
{
playerInfo.text = "Fire Rain spell is not ready. (" + (int)(nextFireRainCastTime - Time.time) + ")";
timeDisableInfo = Time.time + 5f;
return;
}
playerInfo.enabled = false;
spell_type = SPELL_TYPE.FIRERAIN;
currentSpellCost = firerain.GetComponent<FM_FireRain> ().manaCost;
if (currentSpellCost > pAtt.currentMana)
return;
if (!placingSpell)
{
placingSpell = true;
spellTemp = Instantiate (firerain, GetMousePosition (), Quaternion.identity) as GameObject;
}
}
Then, the code of my prefabs “FM_FireRain.cs” (NetworkBehaviour)
[ClientRpc]
public void RpcStartSpell()
{
isEnable = true;
GetComponent<BoxCollider> ().enabled = true;
particle.SetActive (true);
Destroy (gameObject, lifeTime);
}
My prefabs is register on the NetworkManager. And his structure is like this :
→ SpellBoundary (FM_FireRain, Box Collider, Network Identity, Network Transform)
|
→ FireRain (particle system)
→ SpellPlacer (particle system)
My problem is:
When i click on “Spell1” Button, i saw my object (SpellPlacer particle system). But when i click on “Fire1” button, my particle system (FireRain) doesn’t appear (despite ‘particle.SetActive(true)’ on RpcStartSpell())
It work on the “client/host” side, but not on a remote client…
Thanks for your help.