简体   繁体   中英

Making two object collide but moving like kinematic objects

I'm working on a "Words in a pic" clone and I have different images representing each letters and empty boxes where the letters should be put in to.

When I drag the letters I want them to be dragged like when it is a static body ie just up, down, left and right (no turning or spinning) and when the item is within the box it should stay within that box, otherwise it should go back to it's original position.

The thing is that static objects can't collide with another static object nor can a kinematic object collide with another object so I need to use Dynamic if I have understood it correctly?

However how do I do so when the drag event is activated the body, the letter image, moves like a static or kinematic body (only up, down, left and right) but also detects collision between a letter image and a empty box image?

Thanks for helping me with this, I have not been able to find any information on how to solve this problem!

这比我容易得多,您将项目设置为“ dynamic”,然后将object.isSensor = true设置为不旋转object.isFixedRotation = true并通过object.gravityScale = 0禁用重力。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM