- Home /
Why do 2D objects collide differently inside camera's view vs outside?
Consider spawning 2 sets of GameObjects with 1 set in the camera's view and the second outside. All relative positions are identical, so essentially you have two copies of the same set of GameObjects.
Motion on all GameObjects is controlled by the same script, attached to them as a component. Change in position is done using Rigidbody2D's AddForce, and rotation by Rigidbody2D's AddTorque, all as a result of player input (WASD).
If any of the objects collide, the set that is within the camera's view move one way, while the set outside of the camera's view have different resulting motion from those same collisions. If all objects are placed in the camera's view, then both sets behave exactly the same. If all objects are placed outside of the camera's view, then both sets again behave exactly the same.
These 2D sets of objects are offset only in the Z axis. Since the 2D collision engine doesn't care about Z, normally they would all bump into one another. I've made each set to have a different collision layer, so objects separated in Z in this simulation do not interact with one another.
I'm guessing there's something about rendering the objects that affects the physics engine / collisions?
Your answer
![](https://koobas.hobune.stream/wayback/20220612232444im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Removing scenes with set conditions 0 Answers
Camera following player in Tutorial Demo (Roll A Ball) 0 Answers
CAVEs, OpenGL stereoscopy and camera frustrums 1 Answer
re-entering on the opposite side? 1 Answer
Problem after collision2D ? 1 Answer