[BEHAVIOR] Chipmunk Physics

3 favourites
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • I did not implement saving and loading state with this. I haven't reasoned about what side effects this would cause but it probably causes the effects you see.

  • Okay, yeah.

    Not sure how this will effect things, but this is what I did to remove the pausing:

    	// called when saving the full state of the game
    	behinstProto.saveToJSON = function ()
    	{
    		// return a Javascript object containing information about your behavior's state
    		// note you MUST use double-quote syntax (e.g. "property": value) to prevent
    		// Closure Compiler renaming and breaking the save format
    		return {
    			// e.g.
    			//"myValue": this.myValue
    			"lastUpdateTick": this.behavior.lastUpdateTick
    		};
    	};
    	
    	// called when loading the full state of the game
    	behinstProto.loadFromJSON = function (o)
    	{
    		// load from the state previously saved by saveToJSON
    		// 'o' provides the same object that you saved, e.g.
    		// this.myValue = o["myValue"];
    		this.behavior.lastUpdateTick = o["lastUpdateTick"];
    		// note you MUST use double-quote syntax (e.g. o["property"]) to prevent
    		// Closure Compiler renaming and breaking the save format
    	};
    [/code:1khl2d9h]
    
    I did that because I noticed this:
    
    [code:1khl2d9h]behinstProto.tick = function ()
    	{
    		var timescale = this.runtime.timescale;
    		if (this.runtime.tickcount > this.behavior.lastUpdateTick && timescale > 0)
    		{[/code:1khl2d9h]
    
    Since loading a savestate changes the tickcount, it waits until the tickcount catches back up to where the behavior has it set to.
    
    Not sure if it will have any side-effects.
  • The idea there is to only run the physics simulation once per tick. You probably could just check if the last run tick is different than the current one:

    this.runtime.tickcount != this.behavior.lastUpdateTick

  • Oh! okay, that makes sense. I'll do it that way rather than mess with the saving/loading stuff. thanks!

  • R0J0hound

    I want to create a rigid joint like that:

    https://drive.google.com/file/d/0B8g2b8 ... sp=sharing

    but Physic behavior not support "collision Filter", so I have to use Chipmunk behavior.

    How do I create a rigid joint by only one action in Chipmunk Behavior?

    Thank you!

  • hi , have chipmunk grabling hook tutorial or exaple capax ?

  • Any future plans to port the Plugin over Construct 3? This would be freaking awesome! Because the standard box2d Plugin has some performance laggs

  • Any future plans to port the Plugin over Construct 3? This would be freaking awesome! Because the standard box2d Plugin has some performance laggs

    If you read the thread 2 pages back - you will see the following post from R0J0hound that states he has no plans to convert to C3: https://www.scirra.com/forum/behavior-chipmunk-physics_p1136595?&sid=1aa581358862d0efd568915895ec0b14&sid=5ad861a2a0f2991e7b053c091fb3ed82#p1136595.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Can someone help me with collision layers? I cant get it to work. I know how it works with groups. But i need that two objects in one Layer would collide together, but both objects are attached on one object and they are all in one collision group

  • I know this has already been asked (With no response as far as I can see.) but how the hell do you use the collision layers? The tip it gives "If two objects with this bitwise anded together is non zero, they can collide." makes no sense to me. PLEASE HELP!!!

  • If you think of the layer property as binary you have 8 separate layers. The objects can be in all the layers or even a few of them. For example “11111111” would be all the layers, “00000001” would only be the first one, and “01010101” would be every other layer. Anyways any two objects will collide only if they share a layer. For example an object in layers “00001111” will collide with an object in layers “00000001” because they are both in the first layer. Whereas an object in layers “11110000” won’t collide with an object in layers “00001111” because they have no layers in common.

    You can also look at the chipmunk documentation linked in the first page for another explanation. You actually have 32 layers if you treat layers as hexadecimal.

    “Bit wise and” is a way to check if two numbers have bits in common.

  • Hi, R0J0hound

    I am trying to make my own ragdoll system with your physic and Spriter. My problem:

    when I spawn physics sprites, it inherit angles of spriter animation. So, for example: head has 3 degrees and body has 355 degrees. I connected it with piviot joint which is works nice, and rotary limit joint (limits: -50 and 50), which brake everything, because the limits between 355(body) and 3(head) too big for chipmunk math(but we understand it just 8 degrees). meanwhile if I turn a bit the spriter animation, and body becames 5 degrees and 13 for head, all works ok.

    Any idea?

  • When I check the collision layer expression, it gives an odd number.. how do I translate it to the 00000000 format?

    for example I get 268435456 but I need it to read 10000000 (the layer it is set at)

    nvmind.. I'm implementing an expression into my own plugin that will do this.. i found way to convert using javascript

  • Hello R0J0hound - I am attempting the old chestnut "Weld two objects together so they act like one object".

    While I think it can be achieved using joints this seems unnecessarily inefficient.

    I noticed in the Chipmunk documentation - "You can attach as many shapes to a single body as you need to in order to define a complex shape." - this seems much more like what I want.

    Is there any way of doing this with your plug-in?

    I suspect the answer is No given the constraints of how Construct 2 works, in which case what joint do you think might be the least inefficient way to achieve this?

    Cheers,

    RR

  • RattyRat

    You can't do that with the plugin, and modifying it to do so will have lots of caveats. The idea came up when I was making the behavior but I opted for making things easier to use. It's something best served by a ground up re-write and re-design of how it deals with the js library. I'm not really modifying or creating plugins or behaviors lately though. Lots of work for little gain imo. I have other more entertaining and interesting projects i'd want to do first, but if those succeed I may not be back.

    Anyways, the behavior manages the conversion of c2 coordinants to chipmunk coordinants, and vise versa. The complication is c2 uses the origin as the object center and chipmunk uses the center of mass (COM). To have multiple objects welded together they'd have a shared COM, and it would have to be updated every time things are moved with anything but the physics engine. There are other properties that would need to be updated as well. At least that's my thought.

    -cheers

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)