Function rayCast

  • Checks for object colliding with the given line

    Parameters

    • line: Line

      line to be tested for collision

    • Optionalresult: Renderable[]

      a user defined array that will be populated with intersecting physic objects.

    Returns Renderable[]

    an array of intersecting physic objects

    rayCast

    collision

    // define a line accross the viewport
    let ray = new Line(
    // absolute position of the line
    0, 0, [
    // starting point relative to the initial position
    new me.Vector2d(0, 0),
    // ending point
    new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
    ]);

    // check for collition
    result = me.collision.rayCast(ray);

    if (result.length > 0) {
    // ...
    }