why trigger doesn't work at first time?
hi unity community I made a scene with a box and a gate then I wrote a script for the gate to when triggered with box count the box and play sound and ... but when I start the game for the first time it doesn't work(doesn't trigger)but when I restart the game(SceneManager.LoadScene) it works correctly.
void Start()
{
Application.targetFrameRate = 60;
Time.timeScale = 1f;
audiuo_sorsce = GetComponent<AudioSource>();
}
private void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == color_name1_g)
{
add_point();
print("OnTrigger");
}
else if(collider.gameObject.tag == color_name2_r)
{
loss_point();
}
}
Answer by bookmak123 · Nov 09, 2021 at 07:38 AM
I restart unity and the problem was solved I think it was a unity bug.
Your answer
Follow this Question
Related Questions
Object moves when game starts, but shouldn't until player collides with trigger 0 Answers
Problem dealing with colliders in a complex project [SOLVED] 0 Answers
Player Dies when punching an enemie/traps 1 Answer
Color Change on Collision Without Object Disappearing 0 Answers
Animation trigger doesnt play when collide with trigger 1 Answer