Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raycasting functions #30

Open
suchipi opened this issue Feb 19, 2020 · 4 comments
Open

Add raycasting functions #30

suchipi opened this issue Feb 19, 2020 · 4 comments
Labels
2d Related to @hex-engine/2d help wanted Extra attention is needed

Comments

@suchipi
Copy link
Owner

suchipi commented Feb 19, 2020

Hex Engine should include some ray-casting and collision detection functions out of the box, that use information from the Geometry component. I haven't written them already because I don't know much about ray-casting or which formulas are commonly used to implement it effectively. I would definitely appreciate some help with this.

@suchipi suchipi added help wanted Extra attention is needed 2d Related to @hex-engine/2d labels Feb 19, 2020
@andre-lima
Copy link

I don't know how the best pratices for raycasting are either, but I did develop one prototype for use with the Kontra game engine.

Here's the link for the demo, with the link for the code inside: https://kontra-experiments.netlify.com/
Also, a discussion about the experiments which may inspire you for other features: straker/kontra#136

@suchipi
Copy link
Owner Author

suchipi commented Feb 23, 2020

Thanks for sharing! I will take a look. Hex Engine's raycasting requirements aren't exactly the same as Kontra's (since entities can be non-rectangular), but I can probably get some good inspiration from your Ray class. Thanks again!

@Reklino
Copy link

Reklino commented Mar 2, 2020

Yo! Pretty new to game dev, so excuse my ignorance 😅.

I've been doing some light research on collision detection. Would it be accurate to say that we'd want to support these three types of collision detection?

  1. Axis Aligned Bounding Box (detects collision between two rectangles)
  2. Separating Axis theorem (detects collision between two convex polygons)
  3. Circle Collision( technique that detects collision between two circles)

1 and 3 seem simpler to solve: MDN collision detection

2 seems a way more complex, but this lib looks promising.

@suchipi
Copy link
Owner Author

suchipi commented Mar 3, 2020

Yup, that sounds about right; though we'd also need to support collision between circles and polygons (and vice versa). But we can use circle-like polygons to do that, if needed.

Thanks for the links! They'll be super helpful.

Something else that may be useful is this library, which decomposes an arbitrary polygon into its convex pieces: https://github.com/schteppe/poly-decomp.js/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2d Related to @hex-engine/2d help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants