[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Tue Jan 27, 2015 1:21 am

@R0J0hound , thanks, yea I can probably just taper the sides of the player for simplicity sake for now..

btw, I found an issue- some reason this capx isn't finding the collision point..
Also, why can't we get new collision points after the first collision? if a line falls down, it only gets the first end that touches and never the last end..
I need to figure out a way to find both collision points when a line has both ends colliding, or when the new end collides.. some reason it only registers the first collision.
edit: I guess it doesn't register the second collision if it is already touching?.. hrmm..
You do not have the required permissions to view the files attached to this post.
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Tue Jan 27, 2015 3:49 am

"on post collide" is only triggered when two objects first collide (useful for sound). I need to add another condition to loop over all the collision pairs so you can check at any time.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Tue Jan 27, 2015 3:53 am

@R0J0hound , hm okay.
I'm having issues with the joints expressions.. not sure what is happening.. I add a tag to one object, and it is adding the same tag to another object, so if an object depends on whether a tag exists or not, it won't be accurate because it shouldn't have the tag.. maybe I can make a simple capx to show the issue...
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Tue Jan 27, 2015 4:12 am

@R0J0hound , okay I found the bug..
the capx has two instances that fall.. one hits the tilemap which adds a joint called "test"
the other instance, when it is below y position of 300, will add a join to tilemap called "test2"
I have a text object that counts how many joints with tag "test" .. it should be one, but it shows two.
You do not have the required permissions to view the files attached to this post.
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Tue Jan 27, 2015 5:22 am

Update 2.0:
Download in first post.

* Fixed: Joint tags were not working.
* Added: "for each collision pair" condition. "on post collide" only triggers when an object first hits. This will loop through all the current contact pairs.

Document tidbit:
Joint tags can be any string when adding joints. When using it in joint expressions you can also use a number index.
So do this to get the type of the first joint
Sprite.Chipmunk.jointType(0)
Or the second:
Sprite.Chipmunk.jointType(1)

Also you can give more than one joint the same tag name. Using it in a expression will give the last joint with that tag. This allows you to modify the joint that was just added.
So if you added two pin joints, both with a tag of "". Then the following expression will get the impulse applied to the second joint.
Sprite.Chipmunk.jointImpulse("")

Also attached is an example using the new "for each collision pair" condition.
You do not have the required permissions to view the files attached to this post.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Tue Jan 27, 2015 7:30 am

@R0J0hound , awesome..
found a bug when you set object to immovable yes after adding a joint, it will cause an error.. I did this during on post collision- not sure if it happens outside of that.
I'm also getting some errors sometimes- not sure why yet.. saying that can't set body angle to nan.. I think it happens when it tries to set angle towards position and the position is ontop of itself.. or something.. not sure though.. this happens during on post collision.
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Tue Jan 27, 2015 8:55 am

@R0J0hound

Does this mean we can create bridge building type games where the stress on joints can be calculated ?
B
48
S
16
G
9
Posts: 1,098
Reputation: 11,197

Post » Tue Jan 27, 2015 10:25 am

@R0J0hound, Am playing with the plugin and wanted to create Newtons cradle, something like this in the video - https://www.youtube.com/watch?v=I5N10c3 ... 38FB390970 ( after 25 seconds).

Attached is my .capx file. I am facing 3 issues -

1. Issue#1 - When I have only one ball dragged to the left and released, it works fine. But when I drag the ball to almost horizontal(90 degrees) and release, then I notice the right most ball goes beyond 90 degrees ( against conservation energy law)...Any idea what could be the issue?
2. Issue#2 - When DragTwo group is enabled (let chipmunk Immovable to Yes be still disabled), then it drags two balls to the left on touch. When touch is released, somehow the collisions are not working as they way they should in Newtons cradle...The third ball from the left doesnt go as much high as the right most 4th one...
3. Issue#3 - When I try to set ChipmunkImmovable to Yes on touch and then to "No" on touch released, it gives me a javascript error in the plugin behavior. Not sure if this is a bug.

Please let me know if this can be done as demonstrated in the video above? Having done many physics simulations, I have always found achieving NewtonsCradle to be pretty difficult using Box2D physics - revolute joints somehow...Chipmunk helps me to get this a bit further but still I seem to be struck...
You do not have the required permissions to view the files attached to this post.
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Tue Jan 27, 2015 12:36 pm

@kmsravindra

This version works more like it should, although there are some odd bouncing effects.
You do not have the required permissions to view the files attached to this post.
B
48
S
16
G
9
Posts: 1,098
Reputation: 11,197

Post » Tue Jan 27, 2015 1:07 pm

@spongehammer, Thanks...But all the 3 issues that I have mentioned above still exist...None of them go away
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests