physicsjs - Allowing specific bodies to collide with edges but not with other fixed bodies -


i'm using edge-collision-detection behavior add collisions edge of viewport, , body-impulse-response behavior respond these collisions colliding bodies bounce off "walls".

however, can't seem make body-impulse-response work given bodies , edges (body-impulse-response has no applyto method apparently?), bodies colliding other fixed bodies though don't want them too.

how can fix issue?

thanks!

i found possible solution:

the body-impulse-response behavior works on collisions in given channel. instead of trying restrict behavior specific bodies using applyto(bodies), can change channel collisions being reported on, , give channel input body-impulse-response behavior.

(incomplete) example:

phyiscs(function(world) {     var viewportbounds = physics.aabb(0, 0, viewportwidth, viewportheight);      world.add(physics.behavior('edge-collision-detection', {         channel: 'collisions-edge:detected',         aabb: viewportbounds,         restitution: 0.7,         cof: 1     }));      world.add(physics.behavior('body-impulse-response', {                 check: 'collisions-edge:detected'     }));      /* can add body-collision-detection behavior default       * collisions:detected (or custom name) channel, ,      * body-impulse-response added above won't respond these collisions.      */ }); 

if have different/better solution - please share it!


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -