# [BEHAVIOR] Chipmunk Physics

### » 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.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » 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
97
S
36
G
131
Posts: 5,519
Reputation: 83,476

### » Wed Apr 20, 2016 7:49 am

Nice work hound
B
265
S
49
G
15
Posts: 2,022
Reputation: 42,709

### » 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
91
S
44
G
17
Posts: 1,012
Reputation: 18,572

### » 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
97
S
36
G
131
Posts: 5,519
Reputation: 83,476

### » Wed Apr 27, 2016 6:38 pm

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

### » 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
97
S
36
G
131
Posts: 5,519
Reputation: 83,476

### » 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
91
S
44
G
17
Posts: 1,012
Reputation: 18,572

### » 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,807

### » 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
97
S
36
G
131
Posts: 5,519
Reputation: 83,476

PreviousNext