Search Unity

Correctly designing a networked Skill System

Discussion in 'Multiplayer' started by Tiny-Tree, Dec 20, 2014.

  1. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    Hello,

    I am entering a stage in a project where i am redesigning the base class for the skill to be used within photon cloud, here is the setup:

    -they are used by every Unit ( player or enemy)
    -skills will be prefabs loaded in the Unit as a child.
    -Inside the skill we have a pool of renderer for example 1 ExplosionParticle if the skill can be used every 30 sec
    -I will use an RPC which check (if i own the object >ExecuteLogic) we execute the logic like this for exemple:
    Code (CSharp):
    1.  
    2. //[will be RPC Later]
    3. public override void UseAbility()
    4.     {
    5.         base.UseAbility ();
    6.      
    7.         if (ExecuteLogic)
    8.         {
    9.             UseEnergy();
    10.             SetBuffStats();
    11.             _target.transform.SendMessage ("ReceiveBuff",buffStructure,SendMessageOptions.DontRequireReceiver);
    12.         }
    13.  
    14.         //Spawn the Renderer +sound  on target
    15.  
    16.     }
    -Each Unit Have a SkillTargetSlot, which is the enemy we are attacking, its synchronised using OnSerialize
    -When the skill is activated the renderer+sound are parented & enabled into the target, when skill is over Disabled and reparented into the SkillParent
    Code (CSharp):
    1.  
    2. //Triggered by event after UseAbility RPC
    3. public override void DespawnAbility ()
    4.     {
    5.         base.DespawnAbility ();
    6.         //Disable Renderer
    7.         //Disable Sound
    8.  
    9.         //Renderer.parent = this
    10.         //Sound.parent = this
    11.     }
    Well now considering this setup, what would be the Best/Simpliest solution:
    - if i Want the Unit to be able to Swap Skills ( destroy/ instantiate a new one), should i use photonNetwork.instanciate to be sure every unit equip the same skill ?
    - is it possible to avoid to have a photonView on EachSkill if i reference the Unit PhotonView?
    Code (CSharp):
    1. _caster.UnitPhotonView.Rpc(..);
    Any advice on some change? better solution?