'How to make an object not able to pass through an object? Unity
The title doesn't really explain much so ill expand more. I'm making a 2D game where you move a mouse to help you do stuff. I am using a fake mouse which is controlled by your mouse. And I want to make it so the mouse can't just move through walls. I've tried adding rigid bodies but the mouse still passes through it, or the wall just gets pushed by the mouse. (The mouse has a RigidBody2D script on it and a polygon collider 2D and the wall has a box collider 2D, and a RigidBody 2D) Thanks for the help.
Solution 1:[1]
If both have what you say, mouse has rigidbody + 2d-collider and walls have 2d-collider then it should work. A few things to note: it will only work if you move by physics (ie not teleporting each frame) and don't move it too fast (change rigidbody collision setting to "continous" if so). – Fredrik Schön
This solved it for me, Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TheBlueToo |
