Hi.
Trying to make elastic drag effect like on the video:
http://dl.getdropbox.com/u/989832/elastic-video.mov
Tried to use joints (one of the body has infinite mass), but ball just moved to the target without any elastic effect.
How this effect could be implemented?
Thank you!
Elastic joint(?)
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Elastic joint(?)
Looks like they simply damp the velocity of the white ball and apply a spring force towards the control point.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 4
- Joined: Tue Oct 20, 2009 11:01 am
- Contact:
Re: Elastic joint(?)
Should I connect the controlling ball with moving ball using a joint?
Seems the force applied to the moving ball depends not on the controlling ball's velocity but on their distance.
Seems the force applied to the moving ball depends not on the controlling ball's velocity but on their distance.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Elastic joint(?)
No joints. Just damp the velocity (v = v*0.99 or somesuch) and apply a force based on how far the ball was from the control point (f = (point - ball_center)*some_number)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 4
- Joined: Tue Oct 20, 2009 11:01 am
- Contact:
Re: Elastic joint(?)
Thank you for the answer.
But the applied force will infinitely move the ball without spring effect? Maybe an impulse should be applied? Or every time ball flies over the control point we should apply a force with negative direction to the current force with damping coefficient?
One more question: after applying an impulse body never stops like there's no friction (body is in the air, without gravity). How to simulate air friction?
Also body never stops after applying an impulse while it's on the ground (but body and ground have non-zero friction coefficients). Body is a circle.
Even if I add surface_v to the ground my body is just rotating at the same position, it does not move.
Thanks!
But the applied force will infinitely move the ball without spring effect? Maybe an impulse should be applied? Or every time ball flies over the control point we should apply a force with negative direction to the current force with damping coefficient?
One more question: after applying an impulse body never stops like there's no friction (body is in the air, without gravity). How to simulate air friction?
Also body never stops after applying an impulse while it's on the ground (but body and ground have non-zero friction coefficients). Body is a circle.
Even if I add surface_v to the ground my body is just rotating at the same position, it does not move.
Thanks!
-
- Posts: 4
- Joined: Tue Oct 20, 2009 11:01 am
- Contact:
Re: Elastic joint(?)
Thanks again, I got the desired spring effect =)
That is done on every tick:
That is done on every tick:
Code: Select all
ballBody->v = cpvmult(ballBody->v, .93);
distDiff = cpvsub(mBallBody->p, ballBody->p);
forceApplied = cpvmult(distDiff, 800.);
cpBodyResetForces(ballBody);
cpBodyApplyForce(ballBody, forceApplied, cpvzero);
Who is online
Users browsing this forum: No registered users and 14 guests