[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Sat Jan 24, 2015 11:10 pm

That would be useful. Should the x and y returned be in layout coordinates or relative to the objects? I'm leaning towards "layout" but relative would be constant.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Sat Jan 24, 2015 11:25 pm

Layout coordinates would be more intuitive I think. If it is relative to the objects, you might be forced to choose the object and do something like obj.x + joint.x if you need the layout coordinate.
If it is already in layout coordinates, you won't need to pick the object to do that- and if you need a relative position, you'd more likely want to pick the object anyways.
so, yea I think layout coordinates would be better.

edit: I'm wondering if you need to access the joint through the correct object it was added to? Might be limiting if that is the case. Would be good if you can just find any joint regardless of which object is calling the expression.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Sun Jan 25, 2015 2:40 am

You need one of the connected objects to get info about a joint. Makes sense since event sheets rely on picking, not to mention that's how chipmunk organizes the joints. I can add expressions to get the anchor point of the current object and the connected object. That would save needing to pick the other object.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Sun Jan 25, 2015 3:00 am

ah, I see. I kind of figured that would be the case. Anything that helps not having to pick an object would be great.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Sun Jan 25, 2015 11:35 am

***EDIT: updated the capx***

Here's an example that I thought might be interesting - it's a simple grappling hook that uses the slide constraint & raycasting:

Grapple_example_V2.capx


It's a stripped down version of a more complex system I'm working on (with rope wrapping) so there might be some usused variables & it's not commented very well.
You do not have the required permissions to view the files attached to this post.
Last edited by mattb on Tue Jan 27, 2015 7:02 pm, edited 2 times in total.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Sun Jan 25, 2015 9:47 pm

Just a quick question: Is Chipmunk only meant to function, if you apply it to objects separately instead of applying it straight to a family?

I tried applying Chipmunk to a family of objects (a ragdoll), in a similar way I used to work with Box2d, but as a result I get black screen. Loading of the layout freezes at 30%. However, if I remove the Chipmunk behavior from the family and apply it separately to all the objects in the family, the layout loads and everything works fine.

EDIT:
I guess it was just some gibberish in the cache, now everything is working fine :mrgreen: So one can apply it straight to a family for all the objects in the family inherit Chipmunk =)
B
14
S
3
G
1
Posts: 77
Reputation: 1,035

Post » Mon Jan 26, 2015 9:11 pm

I found a reason why it'd be better to use line segments for the tilemap instead of boxes..
So that you don't get stuck on corners of the boxes when collideing with walls.. here's a screenshot showing th eplayer standing on a corner without falling.
stuck.jpg
You do not have the required permissions to view the files attached to this post.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Mon Jan 26, 2015 10:41 pm

here's an animated gif of the issue.. maybe theres a way to fix it?

cornerstuck.gif
You do not have the required permissions to view the files attached to this post.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Mon Jan 26, 2015 10:52 pm

Update 1.9:
Download in first post.

* Fixed: If a shape or joint was destroyed more than once it would crash.
* Fixed: Expressions would sometimes return undefined if there wasn't any value. Now 0 is returned.
* Added: "set joint properties" action to change joint specific properties after the joint is added. Things like spring stiffness, pin distance, etc ... see note[1]
* Added: A bunch of expressions to get those joint specific properties: see note[1]
joint_PinDist(tag)
joint_SlideMin(tag)
joint_SlideMax(tag)
joint_SpringRest(tag)
joint_SpringStiff(tag)
joint_SpringDamp(tag)
joint_RotaryLimitMin(tag)
joint_RotaryLimitMax(tag)
joint_RatchetAngle(tag)
joint_RatchetPhase(tag)
joint_RatchetRatchet(tag)
joint_GearPhase(tag)
joint_GearRatio(tag)
joint_MotorRate(tag)
* Added: An expression to get the joint's type as text: jointType(tag)
* Added: Expressions to get the points that a joint connects to the objects. Either the current object or the other one:
jointAnchorX(tag)
jointAnchorY(tag)
jointOtherAnchorX(tag)
jointOtherAnchorY(tag)

Note [1]:
If the action or expression used doesn't match the joint type then the action will do nothing and the expressions will return 0.

@Prominent
Line segments might help with that but I currently have no plans to implement it.
You could bevel the player's collision polygon a bit.

-cheers

Edit:
Last minute fix. Re-download version 1.9.
* Fixed: "Enable/Disable" and "Set immovable" actions would crash trying to remove a shape more than once.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Jan 27, 2015 12:31 am

@Prominent
Here's a proof of concept in events to see how it would handle. The result is decent, but it becomes much more complex if we wanted to use tile collision polygons. It would also take a while to implement this in a good js way. So long term I may implement something into the behavior but not at the moment.
You do not have the required permissions to view the files attached to this post.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 5 guests