0

I am using Chipmunk Space Manager. I have my space setup with one ball and a bunch of segments (512 in my case) joined together to make a circle.

My aim is to force the ball to move in that circle as user moves the device. The faster user moves the device, faster the ball will move in circle. The ball has to follow all physical laws as well.

I am getting gravity and userAcceleration components from CMMotionManager but unable to make some sense out of it.

I tried applying force manually and that works realistically, but I am unable to move the ball in the circle depending on how much user moved the device. Like if I put a small ball in a glass and shake the glass, the ball will move in the circular bottom of the glass and comes to rest in the direction of tilt of glass when there is no more external force moving/tilting the glass

1 Answers1

0

I think the easiest way to do it would just be to change the gravity of the space to match the accelerometer. To get smooth circular motion it would probably be best to use a cpSlideJoint with a min dist of 0 and a max dist of the radius of the circle you want to spin it in. It's not possible to make a smooth hollow shape otherwise. You'd have to build it out of many line segments and that might not work very well.

slembcke
  • 1,359
  • 7
  • 7
  • I tried using cpSlideJoint but that is not affordable as I want the ball to stay at the border of the circle, in case of cpSlideJoint ball leaves the circle with rapid change in gravity. Then I used pin joint so that the radius remains fixed, but here the problem is how can I stop the ball as there is no way to offer some friction to the ball so that it stops when user stopped moving device. I added line segments to make the circular border but thats not working as expected. Any ideas please? – Hassan Rasheed Sep 08 '11 at 07:24