[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Sat Aug 29, 2015 1:17 am

I noticed there is the option to disable the chipmunk behavior on an object.
I tried doing this to an object that has a joint with another object, and noticed that the other object still is affected by the joint attached to the disabled object.
Is there a way to disable/enable the joint as well so I don't have to recreate them everytime I want to disable/enable the behavior?
@R0j0hound , maybe an action to disable/enable a joint given its' tagname?
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Sat Aug 29, 2015 8:38 pm

Another useful application of disabling/enabling joints would be if you want to switch between joint types to control the movements of objects that are grouped together in specific ways. I think this could open some unique game mechanics that might be otherwise difficult to manage. This might be obvious to you, but just thought I'd mention it anyways since I think it would be really useful.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Mon Aug 31, 2015 9:34 pm

@R0J0hound there's a minor bug when you try to alter the mass of an object with a polygon collision shape. Not a biggie, the workaround is to set coll shape to box before setting mass, then switching it back to polygon afterwards.

Here's the error message:

Image
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Fri Sep 04, 2015 10:37 pm

help helP!!! i cant figure out how to stick to seperate sprites to each other when they both have physics enabled?? like a helmet on a head stuck, both sharing same rotation an angle? Simple but theres no way and not sure what joint to use.... should i make objects like that immovable and simply set the angle? but what if i need to to interact with normal collisions also? whats the physics way to do it???
B
4
Posts: 27
Reputation: 254

Post » Sat Sep 05, 2015 10:30 am

@jeebroniz here's what rojo said about the joint part of your question:

According to the chipmunk forums the way to join two objects together is with two joints. A pivot and a gear joint. I apologize fo the seeminly complicated formula used for the phase of the gear joint. It's the signed angle difference between the two object angles. angle(0,0,cos(a-b),sin(a-b))


This is the capx he posted: download/file.php?id=12476

The easy way to disable collisions between the two objects while still keeping their physics collisions with other objects active is to set their collision group property to the same non-zero value.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Sat Sep 05, 2015 4:51 pm

mattb wrote:@jeebroniz here's what rojo said about the joint part of your question:

According to the chipmunk forums the way to join two objects together is with two joints. A pivot and a gear joint. I apologize fo the seeminly complicated formula used for the phase of the gear joint. It's the signed angle difference between the two object angles. angle(0,0,cos(a-b),sin(a-b))


This is the capx he posted:

The easy way to disable collisions between the two objects while still keeping their physics collisions with other objects active is to set their collision group property to the same non-zero value.


wow man thanks a ton! , i totally forgot about the obviouys X and Y joint I had used previously to get more rigid hinges..
now i wonder how most people approach AI using a physics enabled environment?
B
4
Posts: 27
Reputation: 254

Post » Sat Sep 05, 2015 6:24 pm

@Prominent
I hadn't anticipated that case where a joint still affects a disabled object. I guess I may need to remove the object further from the sim, as right now it just is removed from the simulation space. To be able to disable joints would also need some some work, since it's not nearly as straightforward as disabling objects is now. This will have to wait until I get to re-reviewing the code.

@mattb
Thanks for the bug report as always. I haven't touched the code for a bit so I need to re-familiarize myself with it. Well, that and I need to then rework a lot of it to address the requests and feature requests of the last few pages. I'll see if I can make some time this week perhaps.
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Post » Sun Sep 06, 2015 10:31 pm

@R0J0hound
@Prominent
@anyone argh
Any idea how to handle damping with a force-based magnet/point attractor so that attracted objects don't overshoot & fly around the centre? I've tried a bunch of expressions where force decreases towards the centre, with an opposing damping force based on velocity, & nothing works.

The current method I'm using sets velocity directly, & it's fine until stuff gets dragged through walls. I'm hoping that forces will solve this, since they're always the recommended way of moving things in physics engines.

https://dl.dropboxusercontent.com/u/523 ... oblem.webm
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Sun Sep 06, 2015 11:50 pm

To dampen the velocity of an object that has forces applied, I think you could just multiply the velocity by something like 0.95 (or a value near 1) every 0.01 seconds or something like that..
To help prevent objects sticking into other objects, you could try moving it out at the angle of the collision's normal a distance of the collision's depth(or maybe it's the negative of the depth?).. You'd get these values on post collision and perform the move then.
That is what I would try.

edit: btw, thanks for the info r0j0hound , I kind of thought it might require a lot of editing, but figured I'd mention it anyways in-case you ever see an opportunity to try it.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Mon Sep 07, 2015 11:54 am

@Prominent
Yeah i've been doing that kind of velocity damping. I want to see if a force only approach is possible, to see if that improves collisions.

Here's a comparison of velocity vs force based magnets (very simple with no falloff or damping, just constant velocity & force applied) to show how much better collls are when you don't mess with velocity:

https://dl.dropboxusercontent.com/u/523 ... rison.capx

EDIT: I think i've cracked it - damping force just needs to be a force opposing the object's angle of motion (chipmunk has an expression for that), proportional to its speed. Throw in a multiplier, negate gravity & it seems to be good, perfect collisions.

new capx - https://dl.dropboxusercontent.com/u/523 ... mping.capx
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 0 guests