Пример #1
0
    public void ShootTowards(GameObject target)
    {
        PlayerProjectile the_projectile = Instantiate(projectile_used, transform.position, Quaternion.identity);
        Vector2          direction      = new Vector2(0.0f, 1.0f);

        direction.Normalize();
        the_projectile.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg + 90.0f);
        the_projectile.GetComponent <Rigidbody2D>().velocity = direction * projectile_speed;
        the_projectile.Target(target);
        // Slightly faster projectiles in the boss stage
        if (spawner.name == "BellSpawner")
        {
            the_projectile.speed = 1.7f * projectile_speed;
        }
        else
        {
            the_projectile.speed = projectile_speed;
        }
        Debug.Log("Shooting the " + spawner.name);
    }