[BEHAVIOR] Chipmunk Physics

3 favourites
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • Im curious about performance on mobile, also will this work with C3 ?

  • You'd have to test it and see how it performs on mobile. I've only tested the html5 export and I was never concerned with performance tests because this is just a wrapper to an existing js library.

    Also as with any third party plugin/behavior in C2 it won't work in C3 unless it's converted over. No plans to do so though.

  • R0J0hound , I'm having an issue with tile collisions polygons. It seems like the polygons are generated fine when the tile is index of 0, but if it is a different index, like tile 1 or 2, etc, the polygons don't combine together.

    Is there a way for me to confirm if this is the case? How can I fix this if it is?

    ..maybe a bug in the tilemap object??

    edit: the tilemap's collision rects property value in debug remains the same when I replace tile type 1 with tile type 0, so maybe it's a chipmunk bug.

  • Okay, so.. here is some more info..

    Seems like if I modify the tile's collision poly, then Chipmunk separates it into another group or something. Moving the points back won't revert it, I had to right click and set the collision poly to bounding box for it to combine properly.

    Maybe there is a flag somewhere that is set if you set the poly to bounding box, and it is toggled when moving the points?

    Anyways.. kind of interesting.. Basically if a tile is considered a polygon(not bounding box), then it won't combine with tiles that are considered of bounding box type.

  • That's expected. It's C2, not the behavior that combines tiles with bounding box collision polygons. I haven't looked in a bit but I'm sure it keeps track with a flag. Once a tile's collision polygon is modified it can't be combined with neighboring tiles. I mean we could come up with something to do it but it wouldn't be fast.

  • Alright- makes sense.

    I only need the bounding box type for my specific case, I was just confused at first but figured out I had to reset poly to bounding box (can't just drag the points to the corners).

    Chipmunk still is very great to use- one of my main reasons I use Construct2.

  • I'm glad it's still useful.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is anyone else having problems with the built-in save/load system, the physics seem to lag behind a fair bit.

    https://www.dropbox.com/s/gsuj4ni4vnjvfj6/chipmunk%20problems.capx?dl=0

    Have you or anyone else found a solution to the pausing after loading a savestate?

  • Saving the game seems to record the tickcount and time, etc... I noticed that loading after waiting a bit causes the pause to be prolonged.. I think the Chipmunk behavior is waiting for the time to catch up to the simulation.. Because when you load, the time/tickcount goes back in time..

    So now, I'm going to explore the plugin and see what can be done about it..

    edit: yep, when I wait and then save game.. then reload the game and immediate load the state, it instantly starts moving because the time being loaded is in the future.

  • 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 ?

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