Trees, rocks, and houses allow the delivery car to go through them

Earlier in the lessons when the car hit one of them it would stop, but now that I have set the Collider on them to be a trigger it goes through them (the trigger works and the car does slow down). Previously, it would stop when it hit these sprites.

If I deselect it being a trigger it now pushes the sprite, which is also different behavior.

I figure it is a difference in some settings from before, but it would be useful to know what the settings should be both so when the car hits the collider it stops and is not able to push it around.

Hi Ivskiprof,

In my personal opinion, the question should rather be: How would you like the game objects/ colliders behave in your project? Depending on your answer, it is easier to suggest a solution for your specific problem than to suggest to “randomly” enable “Is Trigger” here and there, which does not necessarily fix any issues.

Trigger colliders do not trigger any physical behaviour in the game. They are basically ghosts. You mainly use them to detect things.

Non-trigger colliders trigger “physical” collisions with other non-trigger colliders given one of the two colliders involved in the collision event is non-static.

Except that it is not behaving as shown in the lesson video. Yet these settings are not working:

The polygon collider has “Is Trigger” enabled. This means that the tree does not have a “solid” collider. Everything is able to move through it.

Furthermore, the tree has got a dynamic rigidbody attached. This means that the tree is supposed to move. And it might move if something collides with it if “Is Trigger” was disabled.

1 Like

I see what it was. I had to go back to lesson 21 to see that there was no Rigid Body on the other objects and to switch from using OnTrigger2D() to using OnCollision2D(). Once I do that it is working properly. Now I understand how the Is Trigger setting and Rigid Body can change how the sprite behaves.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms