Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Collision detection
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Video games === Video games have to split their very limited computing time between several tasks. Despite this resource limit, and the use of relatively primitive collision detection algorithms, programmers have been able to create believable, if inexact, systems for use in games.{{Citation needed|date=August 2014}} For a long time, video games had a very limited number of objects to treat, and so checking all pairs was not a problem. In two-dimensional games, in some cases, the hardware was able to efficiently detect and report overlapping pixels between [[sprite (computer graphics)|sprite]]s on the screen.<ref>{{Cite web|url=http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0004.html#line95|title=Components of the Amiga: The MC68000 and the Amiga Custom Chips|at=Chapter 1|type=Reference manual|archive-url=https://web.archive.org/web/20180717093216/http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0004.html#line95|archive-date=2018-07-17|url-status=live|access-date=2018-07-17|quote=Additionally, you can use system hardware to detect collisions between objects and have your program react to such collisions.|edition=2.1}}</ref> In other cases, simply tiling the screen and binding each ''sprite'' into the tiles it overlaps provides sufficient pruning, and for pairwise checks, bounding rectangles or circles called [[hitbox]]es are used and deemed sufficiently accurate. Three-dimensional games have used spatial partitioning methods for <math>n</math>-body pruning, and for a long time used one or a few spheres per actual 3D object for pairwise checks. Exact checks are very rare, except in games attempting to [[Simulation game|simulate]] reality closely. Even then, exact checks are not necessarily used in all cases. Because games do not need to mimic actual physics, stability is not as much of an issue. Almost all games use ''a posteriori'' collision detection, and collisions are often resolved using very simple rules. For instance, if a character becomes embedded in a wall, they might be simply moved back to their last known good location. Some games will calculate the distance the character can move before getting embedded into a wall, and only allow them to move that far. In many cases for video games, approximating the characters by a point is sufficient for the purpose of collision detection with the environment. In this case, [[binary space partitioning]] trees provide a viable, efficient and simple algorithm for checking if a point is embedded in the scenery or not. Such a data structure can also be used to handle "resting position" situation gracefully when a character is running along the ground. Collisions between characters, and collisions with projectiles and hazards, are treated separately. A robust simulator is one that will react to any input in a reasonable way. For instance, if we imagine a high speed [[Racing game|racecar video game]], from one simulation step to the next, it is conceivable that the cars would advance a substantial distance along the race track. If there is a shallow obstacle on the track (such as a brick wall), it is not entirely unlikely that the car will completely leap over it, and this is very undesirable. In other instances, the "fixing" that posteriori algorithms require isn't implemented correctly, resulting in [[software bug|bug]]s that can trap characters in walls or allow them to pass through them and fall into an endless void where there may or may not be a deadly [[bottomless pit (video gaming)|bottomless pit]], sometimes referred to as "black hell", "blue hell", or "green hell", depending on the predominant color. These are the hallmarks of a failing collision detection and physical simulation system. ''[[Big Rigs: Over the Road Racing]]'' is an infamous example of a game with a failing or possibly missing collision detection system. ==== Hitbox ====<!-- Deleted image removed: [[File:GearheadsCollisionBoxSize.png|thumb|A [[Debug menu|debug]] dialogue box in ''[[Gearheads (video game)|Gearheads]]'' controlling an object's hitbox {{Deletable file-caption|Tuesday, 9 July 2024|F7}}]] --> <!-- Deleted image removed: [[File:GearheadsCollisionBox.png|thumb|The hitbox of a ''[[Gearheads (video game)|Gearheads]]'' toy, controlled by the above screen {{Deletable file-caption|Tuesday, 9 July 2024|F7}}]] --> A '''hitbox''' is an invisible shape commonly used in [[video game]]s for real-time collision detection; it is a type of bounding box. It is often a rectangle (in 2D games) or [[cuboid]] (in 3D) that is attached to and follows a point on a visible object (such as a model or a sprite). Circular or spheroidial shapes are also common, though they are still most often called "boxes". It is common for animated objects to have hitboxes attached to each moving part to ensure accuracy during motion.<ref>{{cite web|title=Hitbox|work=Valve Developer Community|url=http://developer.valvesoftware.com/wiki/Hitbox|publisher=[[Valve Corporation|Valve]]|access-date=18 September 2011}}</ref>{{Unreliable source?|date=March 2018|Wikis are not suitable sources.}} Hitboxes are used to detect "one-way" collisions such as a character being hit by a punch or a bullet. They are unsuitable for the detection of collisions with feedback (e.g. bumping into a wall) due to the difficulty experienced by both humans and [[Artificial intelligence (video games)|AI]] in managing a hitbox's ever-changing locations; these sorts of collisions are typically handled with much simpler [[axis-aligned bounding box]]es instead. Players may use the term "hitbox" to refer to these types of interactions regardless. A '''hurtbox''' is a hitbox used to detect incoming sources of damage. In this context, the term ''hitbox'' is typically reserved for those which deal damage. For example, an attack may only land if the hitbox around an attacker's punch connects with one of the opponent's hurtboxes on their body, while opposing hitboxes colliding may result in the players trading or cancelling blows, and opposing hurtboxes do not interact with each other. The term is not standardized across the industry; some games reverse their definitions of ''hitbox'' and ''hurtbox'', while others only use "hitbox" for both sides.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)