So I'm in the middle of making a drag and drop game and want to add collision or at least a way to stop the player from dragging an image out of the canvas. The only problem is I have to make them UI Images. I tried using a box collider on both the broom and one of the objects that need to be swept but that's didn't work. Is there a way I can have the 2 collide with one another?
Asked
Active
Viewed 821 times
1 Answers
0
Collision in Unity works a bit different. I suppose you want to detect the collision by a script using OnCollisionEnter or OnCollisionEnter2D.
These functions works only on rigidbody/collider to collider/rigidbody collision. So you need 1 collider on both gameObjects which one of them have the Trigger on, and at least one of them to have RigidBody.
If you're using 2D Colliders, you'll have to use RigidBody2D.

Yuris
- 186
- 1
- 11