Raycast Solutions, does MX2 have anything like this?

About Monkey 2 Forums Monkey 2 Programming Help Raycast Solutions, does MX2 have anything like this?

This topic contains 5 replies, has 4 voices, and was last updated by  abakobo 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14658

    Amon
    Participant

    Does MX2 have any raycasting functions and if not how would one go about coding one, both for 2d and 3d?

    #14659

    peterigz
    Participant

    Chipmunk has 2d raycasting, and also my own timelinefx has collisions with a raycasting function, there’s an example in the samples folder. Not sure about mojo3d but it uses bullet which must have raycasting functions built into it?

    #14660

    Amon
    Participant

    Would I need to import chipmunk, timeline or bullet to access these? If so then, well, it would do what I need, but, I was hoping for a solution that was part of mojo that doesn’t need any extra imports.

    #14677

    therevills
    Participant

    For 2D I just use Bresenham Line on an array.

    This is MX1 code but you should be able to convert it, it will return an int of a map array (eg the tile):

    #14678

    therevills
    Participant

    Converted an old MX1 example:

    #14679

    abakobo
    Participant

    you can do it with box2d too.
    box2d is not in the form of a module now but it works fine.. the module should be there soonish.
    just download the box2d fork and build these to see it working:

    https://github.com/abakobo/Box2D/blob/mx2/bananas/03-b2djson/e3-raycast_by_fixture.monkey2
    https://github.com/abakobo/Box2D/blob/mx2/bananas/03-b2djson/e5-raycast_by_callback.monkey2

    Edit: you are looking for a non imort solution so therevils’ code should be better!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.