Page 1 of 1
how to slow down mouse interaction
Posted: Thu Feb 25, 2010 5:05 am
by xjpx
Hi|! I'm, trying to make a body hanging on invisible rope connected to user's finger. Here's what i'm doing. I create a body with infinite mass and moment of inertia and don't add it to a space. I connect another body to the body with infinite mass using a pin joint or slide joint. I update position and velocity of the static body as the finger moves. When I move the finger slow around the screen everything works as i expect, but when I make fast movements the suspended object starts to spin around the finger extremely fast. In 4.1 version it did'n happen, it has started since I updated to v5.1 How can I slow it down?
Re: how to slow down mouse interaction
Posted: Thu Feb 25, 2010 10:33 am
by slembcke
First of all, you need to be smoothing the mouse input. Input from the OS is always really coarse, probably running at fraction of 60Hz. Secondly, you need to limit the joint forces so that it can't just whip the attached object around with a nearly unbounded amount of force to make it exactly match what the finger body is doing.
Check out the main Chipmunk demo application. It does these things and has nice smooth mouse interaction.
Re: how to slow down mouse interaction
Posted: Fri Feb 26, 2010 11:09 am
by xjpx
Thanks a lot for your reply! It was really helpful. The only thing that's not clear for me is how maxForce works. If the number I specify is small enough to slow the suspended body down, it responds to fast movements with a delay. Joint looks like it doesn't have constant length but stretches if the finger is moving fast. I've particulary solved this problem by smoothing touch input (using cpvlerp as in chipmunk demo ) and applying more gravity. I also set biasCoef 1. But still there's some delay. Is there a better way to do it? Did I miss something or everything is as it should be?
Re: how to slow down mouse interaction
Posted: Fri Feb 26, 2010 11:42 am
by slembcke
Using a biasCoef of 1.0 can make things unstable, but a maxForce might also help to smooth that out. I guess you could try to increase the maxForce based on how fast things are moving. The issue is that it's just not realistic to allow using an infinite maxForce. Allowing the user to whip an object around the screen without any feedback simply means that they don't know when they are exceeding the limits of the system.