Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>100 objects should easily be able to support collision checking at 100fps, especially in a 2D world. Therefore your algorithm is likely at fault.</p> <p>It sounds like you brute force check each tree against the player; this can get very slow, especially if the trees' geometries are complex. This level of checking can be avoided by using 1 or more broad phases.</p> <h3>Broad phase</h3> <p>In a basic broad phase you check each object that could collide's <strong>bounding box</strong> against each other object's bounding box. It is not important that the bounding box be the precisely the shape of the object, just that it be relatively small, completely contain the object and be a simple shape (axis aligned rectangle is best). Only if this simple check for collision is passed is the more expensive narrow phase check made.</p> <h3>Spacial partitioning</h3> <p>A further refinement is to spacially seperate the region into larger boxes. Thereby allowing you to eliminate collisions against several trees at once.</p> <p>These concepts are illustrated in the below diagram</p> <p><img src="https://i.stack.imgur.com/3wyQM.png" alt="enter image description here"></p> <p>Here the player is shown as a red circle; you can immediately see that there is no point checking any but two of the trees as only 2 trees are inside the same Large box as the player. On checking just the bounding box of those 2 trees you see only one of those could be colliding with the player; you check the fine geometry of the remaining tree to find that it also does not collide.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload