[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Sat Jan 17, 2015 7:41 pm

Hey man!

However, there doesn't seem to be any Angular damping in your plugin... The one on the left is Chipmunk, the one on the right is the default physics behavior. For some reason, the chipmunk one constantly speeds up faster, and faster, rather than staying at a constant speed. (Give it some time, you'll see it's very apparent)

The two black lines are there for collision purposes... (I don't want them colliding with the propeller). The default physics plugin has the ability to disable, or enable specific objects, rather than settings layers, which can cause a problem... but so far it hasn't...

Lastly, I'm guessing the Concave polygon support is what you mean for the behavior it has with colliding with the ball? I notice chipmunk does not support collision polygon's... so perhaps that's why it's not interact the same as I was expecting. :(
You do not have the required permissions to view the files attached to this post.
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sat Jan 17, 2015 9:19 pm

@R0J0hound
Thanks for the mass/size example.

R0J0hound wrote:I'll have to give this more thought to keep things simple. Ideally we could coose from:
layout x,y
imagepoint
relative to orientation of the object *(what's currently done)


My preference would be imagepoint, in keeping with C2's physics behavior. I do prefer your method of object picking by UID though, & it'd be nice if you could put -1 into the UID box as a 'constrain to world' feature.

@Nitro187
For angular damping make a damping variable from 0-1, then you'd add the action: Set Chipmunk angular velocity to Self.Chipmunk.angVel * 1-damping
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Sun Jan 18, 2015 7:53 pm

@Nitro187
You're right there is no angular damping at all so the object would accelerate indefinitely. It can be useful though so I may eventually make damping built in.

The way to disable collisions between object's is to use collision groups and layers. They aren't colliding because they both are in the same collision group.

Actually box2d doesn't work with concave objects either, both libraries need the concave polygons to be converted to multiple convex ones. The built-in physics behavior does this automatically for you, but this behavior doesn't yet.

@mattb
-1 has a useful meaning for uids that means no object. Instead would being able to type "world" be better? It would make it more clear what was intended.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Mon Jan 19, 2015 11:49 pm

Yes that'd be great thanks.

I was wondering, since chipmunk has raycast options could I somehow get a ray hit position & normal (on eg. an immovable sprite) without shooting out physics object then using post-collision info? I see there's a raycast query condition, but that's only for picking the first object hit.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Tue Jan 20, 2015 1:49 am

@mattb
The "pick overlapping line segment" should do it, but it seems to be bugged in the last version I uploaded. The fix will have to wait till I finish with the other stuff I'm adding, which is requiring lots of code changes.

Stuff like this:
https://dl.dropboxusercontent.com/u/542 ... index.html
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Tue Jan 20, 2015 7:58 am

cool, tilemaps.. Hope you provide some detail on how that is handled once you get it sorted how you want it- I'd be interested in knowing how it works. One thing that has me wondering is if the tilemap will get updated if the tiles change during runtime(if you erase or add tiles).
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Tue Jan 20, 2015 8:22 am

Updated to version 1.4:
Link on first post.

* Added the new icon. Credits to @boybacteria.
* Added: Polygons can now be concave. Internally they are converted to convex polygons.
* Added: Tilemap objects now work. See note[1]
* Fixed javascript error with "line segment query" condition.
* Fixed bug with queryNormY expression. Was the same as queryNormX.
* Change: The default sleepTimeThreshold is now 1 second. It was 0.5 before, and objects fell asleep to quick.
* Joints updates:
- Added the ability to use a postion on the layout or an imagepoint to determin where to connect to objects.
- Added: Now you can attach joints to the layout by using -1 for the uid of the second object.

[1] Tilemap notes:
Tilemaps ignore the "collision shape" and "prevent rotation" will always be considered "yes".
The area expression for tilemaps will return 0.
Changes to the tilemap are not detected currently, so the collision won't change if the tilemap is changed. A workaroud is you can force an update by changing the size of the object.

@Prominent
The collisions won't automatically be updated if the tilemap is changed. You can manually force an update by changing the tilemap's width.

-cheers
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Tue Jan 20, 2015 8:44 am

@mattb
Here's an example of the line segment casting. The query conditions also set it's query expressions which can give normal and hitpoint.

"pick overlapping line segment" [*]
Picks all object's whose shape overlap the line. In addition to picking the objects, info about where the line hit, and normal are accessible from expressions which all start with "query".

"raycast and pick first hit"
It's about the same as the one above, but it only picks the first object hit. It also gives the ability to filter out objects by collision layers or group. It sets the query expressions as well.


Note [*]:
"pick overlapping line segment" isn't working all the way with concave polys or tilemaps, but the other condition is working fine.
You do not have the required permissions to view the files attached to this post.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Tue Jan 20, 2015 9:05 am

@Prominent

Thanks!

@R0J0hound

It's indeed a strange name for a physics engine :) Glad you wanted to use the icon! :)
B
13
S
2
Posts: 20
Reputation: 693

Post » Tue Jan 20, 2015 4:30 pm

Rojo this is awesome, it's opened up a huge range of game design possibilities. But it does mean that I now have to rewrite my whole game (probably only with half as many events) :D

I've attached a test capx for everyone to see how raycasting works with the various collision shapes chipmunk has to offer, amazing stuff.

By the way Rojo, the raycast query doesn't seem to work if chipmunk is used as a family behavior. Not a big deal but I thought I'd mention it.
You do not have the required permissions to view the files attached to this post.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests