Example #1
0
    void Update()
    {
        if (enemyCount < 1)
        {
            enemyGenerator.EnemyGenarate();
        }

        if (counter <= 0)
        {
            StartCoroutine(RandomMove());
        }

        float ratioX = (targetLaneX * LaneWidth - transform.position.x) / LaneWidth;

        moveDirection.x = ratioX * speed;

        // 重力分の力を毎フレーム追加
        moveDirection.y -= gravity * Time.deltaTime;

        // 移動実行
        Vector3 globalDirection = transform.TransformDirection(moveDirection);

        controller.Move(globalDirection * Time.deltaTime);

        //体力表示を更新
        textLifeNumber.GetComponent <Text>().text = life.ToString();

        if (life <= 0)
        {
            animator.SetTrigger("Die");
            Invoke("Destroy", 1.0f);
        }
    }