Skip to content

[IDEA] Has anyone played with Collision Detection? #23

@saraford

Description

@saraford

Hey all,

I've noticed the collision detection is hit or miss. I've followed this Issue to tweak the sensitivity, but it is unreliable. I can pick up BB-8 and a collision is detected. But BB-8 can run into a wall and lose its head and no collision detected. Seems that the collision has to be at a certain spot on the ball.

Curious if anyone else has tried to play with collision detection.

Here's my code:

module.exports = function (bb8) {

  console.log("Waiting for a collision");

  bb8.detectCollisions();
  bb8.color("green");

  bb8.configureCollisions({
    meth: 0x01,
    xt: 0x20,
    yt: 0x20,
    xs: 0x20,
    ys: 0x20,
    dead: 0x50
  });

  bb8.on("collision", function(data) {
     console.log("collision detected");
     console.log("  data:", data);

     bb8.color("red");

     setTimeout(function() { bb8.color("green"); }, 1000);
  });

  bb8.roll(200, 0);
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions