Exemplo n.º 1
0
    public override void magic()
    {
        GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball");
        ball = balls [0];
        foreach (GameObject b in balls)
        {
            if ((wiz.transform.position - b.transform.position).sqrMagnitude <= (wiz.transform.position - ball.transform.position).sqrMagnitude)
            {
                ball = b;
            }
        }

        GameObject   instance = GameObject.Instantiate(effect, wiz.transform.position, Quaternion.identity);
        fpull_effect ff       = instance.GetComponent <fpull_effect> ();

        ff.follow   = wiz.gameObject;
        ff.pointto  = ball;
        ff.duration = 0.6f;

        instance    = GameObject.Instantiate(effect, wiz.transform.position, Quaternion.identity);
        ff          = instance.GetComponent <fpull_effect> ();
        ff.follow   = ball;
        ff.pointto  = wiz.gameObject;
        ff.duration = 0.6f;

        Vector2     delta = wiz.gameObject.transform.position - ball.transform.position;
        Rigidbody2D rbd   = ball.GetComponent <Rigidbody2D> ();

        rbd.AddForce(force * delta.normalized);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball");
        effects = new fpull_effect[balls.Length];
        int i = 0;

        foreach (GameObject b in balls)
        {
            GameObject   instance = GameObject.Instantiate(effect, b.transform.position, Quaternion.identity);
            fpull_effect ff       = instance.GetComponent <fpull_effect> ();
            ff.follow   = b;
            ff.pointto  = gameObject;
            ff.duration = 40f;
            effects [i] = ff;
        }
    }