Breaking Joints

Chipmunk2D Bindings for the Unity3D engine
Post Reply
Molt
Posts: 3
Joined: Fri Aug 09, 2013 4:49 am
Contact:

Breaking Joints

Post by Molt »

Is there any way in Chipmunk2D for Unity to find out how much force is applied onto a joint in order to see if it should break/be disabled?

I was experimenting with the engine and reached the point where I had the two sides of a trapdoor stable and held with a pivot, but couldn't see how to have the door fall open when hit with sufficient force without having it open at the slightest contact.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Breaking Joints

Post by slembcke »

Oh shoot. Yes there is, and I forgot to expose it in the Unity binding. I just added it to the code and it will be in the next version.

In the meantime, you can add this to ChipmunkConstraint.cs:

Code: Select all

	/// Get the impulse applied by the constraint on the previous time step.
	/// Divide by Time.fixedDeltaTime to get the force.
	public float impulse {
		get { return (_handle != IntPtr.Zero ? CP._cpConstraintGetImpulse(_handle) : 0f); }
	}
Somebody else pointed out that I should implement proper breakable joints like Unity does, so I'll do that too. ;)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests