[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Wed Jan 28, 2015 6:30 pm

@mattb , I just realized you can use query closest to point to find if a point is inside an object..

it's a condition though.. so can't use it like an expression. :\
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Wed Jan 28, 2015 9:56 pm

Updated to 2.1
Download in first post.

*Fix: Setting object to immovable after creating a joint in a "pre step" or "post collide" condition. Actually the fix should correct any errors claiming stuff is being added twice.
*Fix: Setting immovable to No when it was immovable caused and error.
*Fix: Angle would become nan if both connected bodies of a joint were immovable.
*Fix: choosing 'Is disabled' condition would give 'For each collision pair' instead.
*Fix: Error about removing/adding shape that isn't or already is in space.

@keepee
Thanks, it was a typo on my part. I'm surprised that C2 didn't complain about that one.

@Prominent @mattb
Using the custom movement behavior isn't ideal for that sort of thing. Attached is a way to find the point on the edge of a shape. toggle between events 3 and 4.
Event 3 uses the contact depth and normal to find the point on the edge, which works for other object's corners, but not the current object's corners. Not much can be done there as it's how the library works.
Event 4 uses the query from point condition to find the closest point on the edge. This probably won't work the way you want with tilemaps though.

Contact points are only accessible from under the "post collide" and "for each collision pair" conditions. So yeah you'd need to save the info to variables to use outside of that.

A segment query from the object's center to the contact point may be one solution.
You do not have the required permissions to view the files attached to this post.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Wed Jan 28, 2015 10:16 pm

@R0J0hound , I get immediate error in my game now when collision happens.

Error: Assertion failed: Body.activateStatic() called on a non-static body.
at assert (http://localhost:50000/rojoChipmunkBeta ... or.js:51:9)
at Body.activateStatic (http://localhost:50000/rojoChipmunkBeta ... .js:4277:2)
at behinstProto.updateCOM (http://localhost:50000/rojoChipmunkBeta ... js:6967:10)
at behinstProto.updateShape (http://localhost:50000/rojoChipmunkBeta ... .js:6714:8)
at behinstProto.changeShapeCheck (http://localhost:50000/rojoChipmunkBeta ... js:7064:10)
at behinstProto.postCreate (http://localhost:50000/rojoChipmunkBeta ... .js:6882:8)
at Runtime.createInstanceFromInit (http://localhost:50000/preview.js:3247:28)
at Runtime.createInstance (http://localhost:50000/preview.js:2885:15)
at SysActs.CreateObject (http://localhost:50000/system.js:1337:33)
at Action.run_system (http://localhost:50000/eveng.js:1743:20)

edit: seems to happen if create object on post collision.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Wed Jan 28, 2015 10:29 pm

Hmm, that's no good. I'm out of time today, so it'll have to wait till tomorrow. In the meantime you can try and comment out line 6714.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Wed Jan 28, 2015 11:38 pm

I commented out line 4277 and put in if(this.isStatic())return;
Not sure how that will affect other things, but it's allowing me to continue developing stuff for now.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Thu Jan 29, 2015 8:12 pm

Update 2.1a:
Download i first post.

*Fixed: Creating object during "pre step" or "post collide"

@kmsravindra
It stops moving due to object sleeping.

You can disable sleeping with the "Global Settings"->"set sleep time threshold" action. A value of Infinity is disabled.

Document tidbit:
The way sleeping works is the object will be put into a non-moving "sleep" state if it's idle for a time equal to or longer than the "sleep time threshold". The object is considered "idle" if it's speed is less than the "idle sleep threshold", which by default has a value based on the gravity.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Thu Jan 29, 2015 8:52 pm

@R0J0hound , I have a question about creating objects during the on post collide. When you create the same type of object as the object calling the post collide, and that object is created in the same position, size, as the original object- does that new object instantly call a post collide event before the current event is finished??
I'm having strange results when I do this, and it seems like it gets called more than it should- so objects keep getting created even when I check to see if the position is the same then don't add one, etc, it still does..
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Fri Jan 30, 2015 12:21 am

@R0J0hound , okay here are some bugs..

first example: object created inside on post collision doesn't get positioned. If you re-enable the joint action, it does for some reason.. weird. Also doesn't get pinned.
chipmunk_posbug.capx


second example: object created inside on post collision doesn't get pinned..
chipmunk_jointbug.capx
You do not have the required permissions to view the files attached to this post.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Fri Jan 30, 2015 1:14 am

Thanks @R0J0hound
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 » Fri Jan 30, 2015 6:10 pm

Update 2.2
Download in first post.

* Fixed: Adding joints in to new objects in "post collide"
* Fixed: Movement actions for new objects in "post collide" were ignored.

@Prominent
In "post collide" new objects aren't added to the simulation till right after the physics step. So they won't trigger a "post collide" till at least the next frame.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 11 guests