- Home /
How can I prevent lagging when objects passing through each other?
I've build an Endless Runner where you control a spaceship, which has to avoid colliding with asteroids and planets. The planets (with rigidbodies and polygoncolliders) spawn in the top of the screen and are getting deleted when they reach the lower end. But here is the problem: 'Cause the planets (and asteroids) don't have the same speed they fly through each other, because I turned the "is trigger" checkbox on, it's causing massive lags. How can I solve this?
Thanks in advance
NOTE: I already tried turning "is trigger" back on, but then the objects collide and causing the same problem.
Answer by JPhilipp · Feb 16, 2020 at 02:54 PM
You can give the planets and asteroids their own distinct layer (see the select box in the top right when clicking on them), then afterwards go into Edit -> Project Settings -> Physics and in the bottom Layer Collision Matrix, untick collisions between this layer to itself. This means all planet-to-planet collisions will be ignored. Good luck!
Your answer
![](https://koobas.hobune.stream/wayback/20220612223419im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Trigger2D not working 0 Answers
How can I destroy an object if it touches NOTHING 1 Answer
platform 2d about collider 3 Answers
*** Trigger Collider2D event only once *** 3 Answers
Creating 'redstone' like wires 1 Answer