[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Tue Apr 19, 2016 12:02 am

I still don't understand the force and impulse section.

Say I want to have an object spawn randomly on my layout and then launch itself at a random impulse value toward a random location on the layout...

Can anyone tell me what do I use to do that? Rect or Polar?

And what does offset mean? I'd like to make the shift over to this, rather than standard physics, but this one part doesn't seem too user friendly.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Tue Apr 19, 2016 12:20 am

@AnD4D
Polar would work for that, just set the angle to the angle to that location from the object and magnitude can be the force amount.

You can ignore the offset if you like. With zeros it's applying the force to the center of mass on the object. The offset specifies a position from the center of mass, which in turn would give some torque.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851


Post » Wed Apr 27, 2016 5:33 am

Just starting to play around with chipmunk physics.

I've setup this little test scene
https://dl.dropboxusercontent.com/u/403350/chipmunktest/chipmunktest.capx

There's 2 things im trying to figure out.

1) If you drag the box upwards quickly, the ball sinks into it about halfway, then slowly pushes up to its proper position. Is there any way to make that quicker? or not sink into the other object at all?

2) If you drag the box down wards quickly, the ball bounces several times like its made of metal or something. Even though elasticity is set to 0 on both objects. Any way to reduce the bouncing?

Thanks!
B
90
S
44
G
17
Posts: 1,012
Reputation: 18,527

Post » Wed Apr 27, 2016 6:18 pm

@justifun
I think the version of chipmunk used is just kind of spongy. The only thing you can tweak is "space iterations" but that has no effect on the sponginess there. It won't be as spongy if you move by changing velocity or even better acceleration I suppose, but that may not always be possible.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Wed Apr 27, 2016 6:38 pm

@R0J0hound - how would you move the square around to follow the mouse via velocity and acceleration?
B
90
S
44
G
17
Posts: 1,012
Reputation: 18,527

Post » Wed Apr 27, 2016 8:04 pm

@justifun
First you need to make the box movable.

velocity way:
set velocity to rect((mouse.x-sprite.x)*10, (box.y-box.y)*10)
and set it to 0 when not dragging

acceleration way:
Keep the box from falling from gravity with:
on box prestep
--- apply force rect(0, -gravity*mass)

and give the box a max speed at the start of the layout.

then to move:
apply force rect((mouse.x-sprite.x)*1000, (box.y-box.y)*1000)

and when not dragging give a slowing force.
apply force rect( -velocityx*1000, velocityy*1000)
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Wed Apr 27, 2016 8:48 pm

@R0J0hound - ill give it a go! I would have never guessed that. I'm new to the physics stuff.
B
90
S
44
G
17
Posts: 1,012
Reputation: 18,527

Post » Sun May 01, 2016 4:14 am

How do I get to use the Chipmunk Physics with construct 2?
B
15
S
7
G
1
Posts: 5
Reputation: 1,797

Post » Sun May 01, 2016 6:00 am

@jkleffel
You can download it in the first post. There's also a sticky topic on how to install plugins.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests