0
\$\begingroup\$

So I've been looking around for a while and can't seem to find an answer for this. I am trying to make a game where you stack shapes as high as possible. I have an OnMouseDrag script so I can grab a shape and put it on top of another. but for some reason when I'm dragging a shape, the shapes will just pass right through each other and glitch and start spinning excessively and also passes through other colliders such as the box colliders 2d on both sides of the screen. If anyone could help me I would very much appreciate it. Thank you.

\$\endgroup\$
  • \$\begingroup\$ It sounds like you're moving your game objects via their Transform component. This is a common error when you want physics-based collisions, because moving with the Transform completely bypasses the physics engine. If you want the physics engine to have a say in where the objects go, you need to talk to it via your Rigidbody / Rigidbody2D component, applying forces/velocities rather than direct position teleporting. \$\endgroup\$ – DMGregory Feb 4 at 17:06
  • \$\begingroup\$ Oh ok. So how would I go about fixing this? \$\endgroup\$ – Grant Scott Feb 4 at 17:09
  • 1
    \$\begingroup\$ See the linked answer, under the heading "So, solutions:" If you need help implementing that advice, please consider editing your question to include more details about what you've tried and where you're stuck. \$\endgroup\$ – DMGregory Feb 4 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.