Скрипт не работает правильно при компиляции на Android - PullRequest
0 голосов
/ 18 октября 2019

У меня проблема в моей игре;когда игрок сталкивается с препятствием, меш игрока проверяется по метке препятствия, если они соответствуют мешу игрока, изменяется. Он работает в редакторе, но не работает после сборки в apk. Кроме того, могу ли я сократить тег сравнения?

Столкновение

 public void OnTriggerEnter(Collider other)
{
    if (Regex.IsMatch(other.gameObject.tag, "^(Cube|Sphere|Prism|[A-Z]) Instance$") == (other.CompareTag(playerMesh.mesh.name)))       //If player collides with an obstacle
    {
        //If the collided gameObject has the same mesh as the player

        for (int i = 0; i < meshes.Length; i++)
        {
            if (meshes[i].name == other.transform.tag[0].ToString())
            {
                Camera.main.GetComponent<Animation>().Play();
                other.GetComponent<AudioSource>().Play();
                StartCoroutine(Hit());
                playerMesh.mesh = meshes[i + 1];       //Changes the player's mesh
                indtX++;
                Alphabetconfig();
            }
        }
        print("sarua");
        GameObject tempCollisionParticle = Instantiate(collisionParticle, transform.position, Quaternion.identity);     //Instantiates a collisionParticle to the player's position
        tempCollisionParticle.GetComponent<Renderer>().material.color = playerRen.material.color;       //Sets its color identical to the player's color
        Destroy(tempCollisionParticle, 1.2f);       //Destroys it after x seconds
    }
    else if (other.CompareTag("Token"))
    {
        gameIsOver = false;
        FindObjectOfType<ScoreManager>().IncrementToken();
        //token sound
        Destroy(Instantiate(tokenParticle, transform.position, Quaternion.identity), 1.2f);
        Destroy(other.gameObject);
    }

    else if (other.CompareTag("Health"))
    {
        gameIsOver = false;
        //healthsound
        stats.playerCurrenthealth++;
        if (stats.playerCurrenthealth > stats.playerMaxhealth)
        {
            stats.playerCurrenthealth = stats.playerMaxhealth;
        }
        Destroy(other.gameObject);
    }
    else if (other.CompareTag("Book"))
    {
        gameIsOver = false;
        //healthsound
        StartCoroutine(ImmuneTime());
        Destroy(other.gameObject);
    }
    else if (other.CompareTag("Wrench"))
    {
        gameIsOver = false;
        //HealthSound
        stats.playerCurrenthealth++;
        if (stats.playerCurrenthealth > stats.playerMaxhealth)
        {
            stats.playerCurrenthealth = stats.playerMaxhealth;
        }
        Destroy(other.gameObject);
    }
    else if (other.CompareTag("Pen"))
    {
        gameIsOver = false;
        //healthsound
        StartCoroutine(FlyTime());
        Destroy(other.gameObject);
    }

    else        //If the tags are different
    {
        stats.Immune = false;
        gameIsOver = false;
        stats.Damage(1);
        if (stats.playerCurrenthealth < 0)
        {
            gameIsOver = true;      //Game is over
                                    //Plays 'deathSound'
            trailRen.enabled = playerRen.enabled = false;
            GetComponent<Collider>().enabled = false;
            FindObjectOfType<GameManager>().EndPanelActivation();
        }

        GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
        //FindObjectOfType<ScoreManager>().IncrementScore();      //Increments score
        //Plays Colides

    }

}

Я знаю проблему, но не знаю, как ее исправить, это как при сборке на Androidфункция обратного скрипта, if становится else и else становится `if. Я не знаю, что происходит, это от редактора или, может быть, мой сценарий?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...