Hi!
I’m making a spell system and i’ve already made certain part of it (recieving data from db of each spell class).
Now my task is to connect these spells with player and make them usable (in network also).
-
Spell Interface class (attached to player):
(also have classes “s”+id (s1, s2, s3))void OnGUI() { if (GUI.Button(new Rect(Screen.width / 6, Screen.height / 1.1f, 120, 40), "FIREBALL")) { CreateSpell(1, this.gameObject, this.gameObject.GetComponent<Player>()._target); } } void CreateSpell(int id, GameObject _caster, GameObject _victim) { createdSpell = GameObject.Instantiate(Resources.Load("Spells/s" + id) as GameObject, _caster.transform.position, _caster.transform.rotation) as GameObject; object s = System.Activator.CreateInstance(Type.GetType("s" + id)); s.GetType().GetField("caster").SetValue(s, _caster); s.GetType().GetField("victim").SetValue(s, _victim); } -
Then spell prefab whith certain script attached is being created.
My task is to add the animations in order to use anim event to instantiate particles or determine the moment when damage is being given. This requires changing my spell structure 'cause methods for animation event are taken from my player’s functions, where THERE IS NOT CURRENT SPELL SCRIPT ATTACHED, it attached on this spell’s prefab.
So help me please to make up the spell structure using animation events!