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 Tharuin

I'd like to change the "one way no collision" prefab collision tiles to allow only my player to jump through them. I don't want my bullets for instance to pass them. So I took a look into collision-map.js and saw that in line 171 might be the key to my answer. Althought I have no idea what to change in order to achiev what I want. I thought about checking for a special variable like Entity.alwaysCheckCollision.

Can somebody tell me if its even possible what I'd like to do and if so, how to do that?

1 decade ago by dominic

One-way tiles are internally handled as slopes. Have a look at the lib/impact/collision-map.js, line 215. That's the default tile definition. You could switch the tile definition out with another one before doing your bullet's update. I.e. something like this (untested):

// Before you start your game, copy the default tile def
// and make the one-way tiles solid:
ig.CollisionMap.bulletTileDef = ig.copy( ig.CollisionMap.defaultTileDef );
ig.CollisionMap.bulletTileDef[12][4] = true;
ig.CollisionMap.bulletTileDef[23][4] = true;
ig.CollisionMap.bulletTileDef[34][4] = true;
ig.CollisionMap.bulletTileDef[45][4] = true;

ig.main( ... );


// in your bullet's update, temporarily switch the collisionMap's 
// tile def while calculating the physics
update: function() {
	ig.game.collisionMap.tileDef = ig.CollisionMap.bulletTileDef;
	
	this.parent(); // physics update
	
	ig.game.collisionMap.tileDef = ig.CollisionMap.defaultTileDef;
}

Also check the Entity's handleMovementTrace() method and the CollisionMap's trace result. Maybe there's a more elegant way to do this?!

1 decade ago by Tharuin

I'm not sure how to use the trace result. When I have the tile and get the tile information with the help of the collisionMap I'm not able to find out the properties this tile information has with log since there are a lot of reports. For what property do I have to check this tile information? I also couldn't find out whats part of it by checking the collision-map.js file.

Also I found a crazy thing happening with these one-side collisions. When I shot my bullet right onto it ( given a 'bottom to top passable' collision tile ) it only sets the Y velocity to 0 and the bullet moves with the speed x: TheCurrentVelocity y: 0 until it hits a solid collision tile. It looks like this collision case isn't handled by "if(res.collision.x || res.collision.y)", because otherwise it would be killed by my code.
Page 1 of 1
« first « previous next › last »