Can someone explain what’s happening here. I have the green dot set up to follow my finger so I can push one of the red dots with it. If I stop pushing a red dot, I can’t push it again until I push the other one. It alternates like that until some point where I can’t push either dot until I restart the program. There are some times where I can push the same dot multiple times, but mostly I have to alternate. I don’t know why the collision isn’t working all the time with the same dot.
fill(0,255,0,255) --green dot
fill(255,0,0,255) --red dots
g1.x=CurrentTouch.x -- position of green dot
Change that last little bit to
g1.x=t.x -- position of green dot
And give it another try
I still get the same results.
.@Mark - doesn’t solve the problem.
@Dave1707. I suspect it’s something to do with the underlying physics routines. There is an underlying physics.contact object which can be at a point of collision, maintained contact or a point of separation. Manually overriding the position of the green circle is sometimes breaking the embedded physics by letting the green appear inside the red circle. Sorry if this isn’t explained very well
Ah. For some reason, if I bounce back and forth between both red circles, the problem doesn’t occur. If I pick on a single dot, it stops responding.
Interesting problem… Now I’ll be happy to hear from someone with a neat solution.
This happens due the bodies falling asleep. Just set sleepingAllowed on the bodies to false (true by default). Bodies are normally woken up when a collision occurs, however just setting the positions of the bodies doesn’t cause any forces to be applied, just overlap separation. I tested my solution and it works just fine now.
Thanks @John, that works just fine. I was also able to make it work by setting g1.gravityScale=.1 and I was getting ready to post that when I saw your post. I didn’t realize that’s what the sleepingAllowed was used for. Glad I had an example to show how it works.