Search Unity

Spell scripting

Discussion in 'Scripting' started by icemaster451, Sep 6, 2011.

  1. icemaster451

    icemaster451

    Joined:
    Sep 6, 2011
    Posts:
    9
    Hi All

    I would like to make a wizard character but im stuck how to make the scripts in c# iv seen this one on youtube
    http://www.youtube.com/watch?v=aDht3p5Gr3M this is like what I would like can anyone point me the way so i can learn to do this?
    tutorials or scripts would be helpful thanks
     
  2. Catsoft-Studios

    Catsoft-Studios

    Joined:
    Jan 15, 2011
    Posts:
    703
    Casting a spell works as any other fire weapons do. Instantiate a "fireball" near the hand of the wizard and script the actions that you want to see when the fireball hits something.

    For example, if you want to destroy something when the spell touches any object use:

    Code (csharp):
    1.  
    2. function OnCollisionEnter(collision : Collision)
    3. {
    4.      // instantiate some particle effect here: Instantiate(transform.position, transform.rotation, ...);
    5.      // This next line will destroy the hited object:
    6.      Destroy(collision.gameObject);
    7.      // And now destroy the fireball:
    8.      Destroy(gameObject);
    9. }
    10.  
    There is no more magic than this ;-)

    PS: Maybe you where asking for something different like the "dissolve" effect that appears when an enemy is hited. I have no idea how to do that, but I think there is a special shader for this in another thread.
     
  3. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
  4. icemaster451

    icemaster451

    Joined:
    Sep 6, 2011
    Posts:
    9
    thanks for the replys ill give this a go