Answer the question
In order to leave comments, you need to log in
Why does the game freeze on OnTriggerEnter?
Good afternoon, I can not understand why the game freezes when the player has OnTriggerEnter.
Move the player at high speed:
void FixedUpdate() {
if (currentWalk != Direction.NONE)
{
checkDirection(); // когда distance <0.1f условие выше не сработает, останавливаю движение
transform.position = Vector3.MoveTowards(transform.position, nextPosition, speed * Time.fixedDeltaTime); //speed = 25f;
}
}
void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Finish")
{
success.SetActive(true); //Пробовал сюда любой GameObject, передаю по ссылке в редакторе
}
}
Answer the question
In order to leave comments, you need to log in
hangs it right now the frieze or crashes right away?
Have you tried to check/repeat in the editor by raising the speed to fantastic?
did you collect the log from the device via Logcat? did you see what was there?
We are sure that OnTriggerEnter() does not affect anything. maybe you have a code for void OnTriggerExit() and at high speed FLYS out of the trigger and some other logic is triggered.
From the described, there is nothing obvious that could break the game - no. search deeper. simplify the test case. debugging and searching. good luck))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question