[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Wed Jan 28, 2015 3:10 am

Maybe there could be an expression that checks if a point is inside an object? Seems like a lot of cases the collision points are within the object, and I need a way to move them out, so I think testing if they're inside and then moving via their normal until they're out might work, but there's no expression to test if a point is in an object at the moment.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Wed Jan 28, 2015 4:46 am

@R0J0hound, This is great...Thank you...Though there are some oddities that I notice at times in the movement of the balls to the ideal newtons cradle, I think this is the closest...
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 » Wed Jan 28, 2015 5:39 am

@Prominent
The contact depth should be the distance from the edge, but I'll look into it. The point query condition will give a negative queryDist when the point is inside a shape.

@mattb
That appears to be how the chipmunk library works. Those contacts flicker on and off when you look at it continually. I'll probably investigate further.

I'll try to get those bugs fixed tomorrow. I'm also going to do some internal tweaks to better address future issues and hopefully prevent them.

Documentation tidbit:
The collision layers property is a list of 32 layers and whether an object is in one or not. I opted for 8 hexadecimal digits instead of 32 binary to shorten it.
The default value: ffffffff means the object is in all the layers. Whereas 00000001 means the object is in that one layer.

If you don't need all 32 layers and don't want to deal with hexadecimal numbers you can use 1 or 0 and have 8 layers.

The objects can collide if any two digits are both 1. For example:

Obj1 00000001
Obj2 11111111
They can collide.

Obj1 00000001
Obj2 11111110
They won't collide.

Obj1 11110000
Obj2 00001111
Obj3 11111111
Obj1 won't collide with obj2 but both can collide with obj3

Another way you can think of it is as a set of rules of what is allowed to collide with what.

Player collides with wall, enemy and enemy bullets but not player bullets
Wall collides with everything
Player bullet collides with enemy and walls
Enemy bullet collides with player and wall
Enemy collides with wall, enemy and player bullet.

Then you assign a layer to each
Wall, player, enemy, player bullet, enemy bullet

And with the rules set the layers accordingly:
Wall 11111
Player 11101
Enemy 11110
Player bullet 10110
Enemy bullet 11001

Another idea would be to have a seperate background layer with something moving and you don't want the player colliding with it. So for that the player's collision layer could something like 0001 and the background 0010.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Wed Jan 28, 2015 7:23 am

Just couple of questions, if you could tell me from the chipmunk_nc.capx file

1. Destroy all connected joints doest affect Pin joint created at the start of the layout?

2. Also could you tell me what exactly is the event checking for joint impulse --> chipmunk destroy joint suppose to accomplish? When I disabled that I didnt notice any visible change whatsoever...
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 » Wed Jan 28, 2015 7:41 am

1
The cursor object only has the spring joint so only that gets destroyed. The pin joints are connected to the sprite object which isn't connected to the cursor object.

2
That event is to demonstrate joint breaking. With the event enabled pull one of the balls down. When you pull far enough the impulse on the joint will get too large and the joint will be destroyed so the ball will break free
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Wed Jan 28, 2015 11:07 am

I get it now...Thank you very much.
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 » Wed Jan 28, 2015 12:03 pm

@R0J0hound this is brilliant, exactly what i'm after, thank you!

@Prominent you might already have tried these, but for checking internal points there's the Pick overlapping point condition, & for moving them back out the Custom Movement behavior has lots of 'push out solid' options.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Wed Jan 28, 2015 12:11 pm

@R0J0hound, sorry to ask one more question on chipmunk_nc.capx...I noticed that when I drag a single ball to the left by a very small angle ( lets say under 10 degrees or so), sometimes the ball stops with nothing happening...sometimes all the balls start moving in a random fashion...Do you think all these are the limitations?
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 » Wed Jan 28, 2015 5:19 pm

hi @R0J0hound, choosing 'Is disabled' condition gives us 'For each collision pair' instead. This seems to be the only bug of it's kind

and a thank you for this behaviour
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jan 28, 2015 6:12 pm

mattb wrote:
@Prominent you might already have tried these, but for checking internal points there's the Pick overlapping point condition, & for moving them back out the Custom Movement behavior has lots of 'push out solid' options.


@mattb , pick overlapping point doesn't work for tilemaps. But I can check what the tile is at a position, and if it is -1 it means it is outside of it. push out solid seems to push them out at closest direction, which may not be accurate. I'm using the normal to push it out so it seems to work.. Sometimes I get it still pushing it out at wrong directions, so maybe I can use push out solid if the normal sends it too far in weird cases...

@R0J0hound , do contact points remain after the on post collision event? Since it only fires once, there's no way to reference the contact point afterwards unless you store it in an instance variable- that's what it seems like anyways.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest