[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Making a paddle...

Making a paddle...

Official forum for the .

Making a paddle...

Postby mani2009 » Tue Nov 17, 2009 8:57 am

mani2009
 
Posts: 5
Joined: Tue Nov 17, 2009 8:36 am

Re: Making a paddle...

Postby slembcke » Tue Nov 17, 2009 10:21 am

Here is how I would do it. Create a body with an infinite mass and moment of inertia, this is the body for the flipper. Don't add the body to the space because you are going to control it manually instead. Create the shape for the paddle, a simple fat line segment or box will do. Add the shape as a normal shape as it will be moving around. Make the center of gravity to be where you want it to pivot. That way all we have to do is rotate the body, and the shape will rotate around the pivot point.

Now, to control the body, you will have to update both it's rotation and angular velocity. When a key is pressed, rotate the body towards the activated position a little each frame. Calculate the angular velocity as (newAngle - oldAngle)/timestep. When the key is released, rotate it back the other way.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Making a paddle...

Postby mani2009 » Tue Nov 17, 2009 1:21 pm

Thanks, got it working, any idea what values of e and u to use to model a pinball? or is it to do with the gravity value set for the space?
mani2009
 
Posts: 5
Joined: Tue Nov 17, 2009 8:36 am

Re: Making a paddle...

Postby slembcke » Tue Nov 17, 2009 2:23 pm

Not really sure. I'd probably start with e=0.6 and u=0.4. That is just an educated guess though. Experiment and adjust.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Making a paddle...

Postby mani2009 » Wed Nov 18, 2009 6:08 am

Thanks
mani2009
 
Posts: 5
Joined: Tue Nov 17, 2009 8:36 am

Re: Making a paddle...

Postby pabloruiz55 » Mon Dec 14, 2009 7:11 am

Sorry to hijack this thread but i also need to make a flipper for a pinball game and was playing with that.

Is it possible to create a pin joint at the point it should rotate and then on update check if the rotation is higher or lower than some number and don't let it rotate past that number?
Is there another way of not letting it rotate past certain angles?
If i do this i would only have to apply an impulse to the other side of it to make it hit the ball.


If i go the "static shape with manual movement" way, would the hitting part be correct? i mean if the ball is near and i make it hit it by adjusting the rotation manually would it hit the ball correctly? I it doesn't, how could i apply an impulse to the ball that simulates the correct behaviour?

Many thanks!
pabloruiz55
 
Posts: 22
Joined: Mon May 18, 2009 7:31 pm

Re: Making a paddle...

Postby slembcke » Mon Dec 14, 2009 9:37 am

In Chipmunk 5 there are angular limit joints that will let you limit the rotation.

For something fast moving like the pinball paddle, I'd still go with the manually controlled approach. It's a little more work, but a lot more likely to look realistic instead of really bouncy/spongy.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Making a paddle...

Postby pabloruiz55 » Tue Dec 15, 2009 5:10 pm

Hi, thanks for the answer!

I am trying to do what you posted before, but how can i change the center of gravity so when rotating it doesn't rotate form the center but from the "anchor" ?
pabloruiz55
 
Posts: 22
Joined: Mon May 18, 2009 7:31 pm

Re: Making a paddle...

Postby pabloruiz55 » Tue Dec 15, 2009 5:33 pm

Ok, i figured that out.

The problem is that i did everything that is posted here but manually rotating the flipper is making the ball go through it... any idea? Thanks!
pabloruiz55
 
Posts: 22
Joined: Mon May 18, 2009 7:31 pm

Re: Making a paddle...

Postby slembcke » Wed Dec 16, 2009 9:48 am

You mentioned "static shape" before. Are you actually adding the paddle as a static shape? Static shapes don't update their collision detection info and cannot be moved. You need to add them as normal shapes.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron