[Technical] How does Construct 2 manage collision?

0 favourites
  • 4 posts
From the Asset Store
12 electronic tracks for futuristic action or adventure games.
  • I used to write my own C++ game from scratch, and I used some data structure such as Quadtree, when there are many objects to speed collision checking up.

    So I am wondering, how does Construct 2 manage collision technically?

  • C2 SDK sounds like the place to check for the codes insight, in peculiar th cr functions rect, quad and their "intersects" methods.

  • Looking at the code it just checks every pair of objects for a collision. It compares bbox first, then rotated box, and poly collisions last. When using behaviors such as 8-direction, the object is compared with every soild object. When using the "is overlapping" condition of sprites only the picked objects are used in the comparison, so you could do some sort of quadtree or spacial hash in events before using "is overlapping".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Both Constructs have always just used an axis-aligned bounding box test to test very quickly if there's no collision (4 number comparisons), then a bounding quad intersection (2 quad intersection), then the full collision poly intersection check. I've been meaning to add some kind of system to reduce the number of comparisons that need to be made, but to be honest, for 2D games the axis-aligned box test is so fast and discards almost all candidates so quickly that I've not felt there's a pressing need for it. You really need thousands of objects before it slows down as it is, and if you use tiled backgrounds properly, you're unlikely to reach that object count.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)