- Home /
Can't make Spell structure and Animation with it
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).
1) 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);
}
2) 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!
Answer by Mmmpies · Jan 04, 2015 at 05:40 PM
@GrahamDunnett is right no one will write your code for you however I stumbled across this months ago on YouTube.
A unity project is attached to that page, it might not be exactly what you want but as an example of what's possible it's pretty impressive.
Oh and as ever, virus scan that attachment, I did and it was fine but it's been on the Internet so always virus scan when you download.
If it helps give them some feedback as well, they were good enough to share it.
Your answer
Follow this Question
Related Questions
Animation events get lost 1 Answer
How to detect if player hits enemy half-way into an animation? 0 Answers
Can the animation editor create local rotational data? 3 Answers
Animator question: need to play animation ONLY if current animation is at a particular frame 1 Answer
Adding animation clips via script 2 Answers