Ejemplo n.º 1
0
    void LaunchMissile()
    {
        Transform targetPosition = GameObjectUtilts.GetNearestObjectTransformByTag(transform.position, "Turret");

        if (targetPosition == null)
        {
            return;
        }

        Vector3 dir = (transform.right * ((int)direction));

        dir.Normalize();

        GameObject objCreatedMissile = (GameObject)Instantiate(objMissile,
                                                               launcherTrans.position,
                                                               Quaternion.identity);

        float      rotZ     = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.Euler(0f, 0f, rotZ - 90);

        objCreatedMissile.GetComponent <EnemyHomingMissileController>().Target    = targetPosition.position;
        objCreatedMissile.GetComponent <EnemyHomingMissileController>().Direction = dir;
        objCreatedMissile.GetComponent <EnemyHomingMissileController>().Rotation  = rotation;
        objCreatedMissile.GetComponent <EnemyHomingMissileController>().moveSpeed = 100.0f;
    }
Ejemplo n.º 2
0
    void DropBomb()
    {
        Transform targetPosition = GameObjectUtilts.GetNearestObjectTransformByTag(transform.position, "Turret");

        if (targetPosition == null)
        {
            return;
        }

        //Vector3 dir = (transform.right * ((int)direction));
        Vector3 dir = -transform.up;

        dir.Normalize();

        GameObject objCreatedBomb = (GameObject)Instantiate(objBomb,
                                                            launcherTrans.position,
                                                            Quaternion.identity);

        float      rotZ     = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.Euler(0f, 0f, rotZ - 90);

        objCreatedBomb.GetComponent <EnemyBombController>().Direction = dir;
        objCreatedBomb.GetComponent <EnemyBombController>().Rotation  = rotation;
    }