Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could have a <code>FireballBehavior</code> inheriting from <code>MonoBehavior</code> AND a <code>Fireball</code> Object not inheriting from anything.</p> <p>Your <code>FireballBehavior</code> would take care of spawning and killing Fireballs as well as keeping track of those on scene, on the other hand your <code>Fireball</code> Object should be completely data driven and only hold the data weapon.</p> <p>Allowing you to send message from the server to the FireballBehavior on any gameObject saying "instanciate that object : Fireball"</p> <p>Am I clear?</p> <pre><code>class FireballBehavior : MonoBehavior { Fireball fireball; public void startFireball(Fireball frb) { fireball = frb; createFireball(); //instanciation and stuff } //your functions handling creation update and killing } class Fireball { GameObject gameObject = prefabFireball; Int agressorId = pId; Int weaponLevel = p.Controller.WeaponLevel; } </code></pre> <p>That way you could just send messages from the network to :</p> <pre><code> gameobject.GetComponent&lt;FireballBehavior&gt;().startFireball(frbFromServer); </code></pre> <p>To sum-up : A generic behavior doing the updates and instanciation according to the data and all the data in a small class or struct handled only by the server and sent from it</p> <p>The advantage with this approach is that it is interchangeable, and as Fireball is a steady state object you can serialize him or store him in database with not too much effort, with just a few changes you could event change Fireball object in FireballBehavior directly during execution to have different fireball at different times...</p> <p>This is an idea derivated from one of those videos : (dont remember which one... but both are very good to watch)</p> <ul> <li><a href="http://www.youtube.com/watch?v=WE3PWHLGsX4&amp;list=PLX2vGYjWbI0Ri-OXGCFHMplbTdgFOUKlE&amp;index=16" rel="nofollow noreferrer">Unite 2013 Scripting behind the scene</a></li> <li><a href="http://www.youtube.com/watch?v=Ozc_hXzp_KU&amp;list=PLX2vGYjWbI0Ri-OXGCFHMplbTdgFOUKlE&amp;index=5" rel="nofollow noreferrer">Unite 2013 Internal Unity tips and tricks</a></li> </ul> <p>To complete the answer you could even have this done a very generic way : </p> <pre><code>class AnyObjectBehavior : MonoBehavior { AnyObject Object1; public void startFireball(anyObject frb) { Object1 = frb; initiateAnyObject (); //instanciation and stuff } //your functions handling creation update and killing private void initiateAnyObject () { myObjectList.add(Object1) //that way you do not have to // use for loops to edit some objects //instanciation stuff } } class AnyObject { //Generic properties GameObject gameObject = prefabFireball; } class Fireball : AnyObject { //fireball specific properties Int agressorId = pId; Int weaponLevel = p.Controller.WeaponLevel; } </code></pre> <p>That way you could just add new classes for any object type you want to instantiate and always use the same behaviorComponent to start update and kill them, and even keep a generic list of all your objects of anyObject type with </p> <pre><code>List&lt;anyObject&gt; myObjectList = new List&lt;anyObject&gt;() {fireball, carrot, chicken} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload