Game Development Reference
In-Depth Information
Unity Raycasting
Collision detection as shown in the last chapter is an easily accessible way of
driving interactions in Unity. It's easy to think of triggers as triggering specific
events or commands, and setting these things up is simple. However, there
are some clear potential drawbacks, the biggest of which is something called
frame miss .
Frame Miss
Unity looks for events on frames. If a game is running at 30 frames a second,
Unity is checking for and potentially firing commands 30 times each second.
Frame miss is a term that refers to actions (like a collision detection) happening
between frames. If it happens between frames, Unity misses it—Unity just
doesn't see it happen. In most cases involving a moving First Person Controller
this is unlikely—the character just doesn't move that fast (unless the collider is
super small); however, let's take a look at a very likely and classic scenario.
Guns are part of a lot of games. They are part of Incursion (although we'll be
shooting cameras and not people). Bullets are fast, really fast, which means
they travel a very long distance in a very short time, or more relevant to us,
they travel a long distance in each frame. Let's assume that a 0.22 bullet
travels at 1500 feet per second. That means if the bullet we create in Unity is
traveling at a realistic speed, if the game is playing at 30 frames per second,
Search WWH ::




Custom Search