Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        //set the velocity vector to zero
        velocity  = new Vector2(0, 1);
        direction = new Vector2(1, 0);


        wizard       = GameObject.Find("Wizard");
        wizardHealth = wizard.GetComponent <FixedMovment>();
        speed2       = 0.05f;
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        //get the direction the fireball is going in from the wizard
        if (GameObject.Find("Wizard") != null)
        {
            Wizard = GameObject.Find("Wizard").GetComponent <FixedMovment>();
        }
        direction = -Wizard.direction.normalized;

        //set the position just in front of the wizard
        rb.transform.position = rb.position + direction * speed * offset;
        rb.MoveRotation(Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg);
        //destroy the object after duration is up
        Destroy(gameObject, duration);
        //set name for collision testing
        gameObject.name = "Fireball";
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        //sets up sword to move in proper direction
        Wizard    = GameObject.Find("Wizard").GetComponent <FixedMovment>();
        direction = -Wizard.direction.normalized;

        //legacy testing code
        //gameObject.transform.position = new Vector3(rb.position.x, rb.position.y, 2);
        //print(gameObject.transform.position);

        //moves sword a little in fron of wizard
        rb.transform.position = rb.position + direction * speed * offset;
        //rotates the sword
        rb.MoveRotation(Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg);
        //removes the sword if it's around for too long
        Destroy(gameObject, duration);
        //changes name for collision
        gameObject.name = "Sword";
    }