Breaking Joints

Chipmunk2D Bindings for the Unity3D engine

Breaking Joints

Postby Molt » Fri Aug 09, 2013 4:53 am

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.
Molt
 
Posts: 3
Joined: Fri Aug 09, 2013 4:49 am

Re: Breaking Joints

Postby slembcke » Fri Aug 09, 2013 8:34 am

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D for Unity

Who is online

Users browsing this forum: No registered users and 0 guests

cron