Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Skywalker

I am trying to use different collision layers depending on what height the player is currently at.

this.collisionMaps is an array of the data arrays for different collision maps
        var cMap = new ig.CollisionMap(ig.game.collisionMap.tilesize, this.collisionMaps[this.groundLevel], ig.game.collisionMap.tiledef);
	this.collisionMap = cMap;
	ig.world = this.createWorldFromCollisionMap(this.collisionMap);
	//this.setupContactListener();
	this.activeCollisionLayer = this.groundLevel;

is my change collision layer function in my main.js

it appears to do everything it's supposed to but when the layer supposedly changes, movement breaks. no errors thrown in console. If I comment out the "ig.world = ..." line, movement still works but the collision layer remains the same since it wasn't updated in box2d.

anyone know how to make this work?

1 decade ago by Joncom

The Box2D world and the objects within it are created in part from the collision map. There is only one collision map and it does not contain additional "layers".

To have multiple collision layers is a strange concept and I'm not use why someone would want this. Can you explain your situation a little more?

There's probably an easier way to do what you're trying to do.

1 decade ago by Skywalker

I was programming an excitebike style racer, and needed to change "lanes" up and down but still be able to jump. I was switching out the collision layer for the "ground" of each lane

I ended up not using box2d, and turned off friction for impacts default collision to work well on slopes for ramps and just wrote my own ground levels and ground collision
Page 1 of 1
« first « previous next › last »