Game Development Reference
In-Depth Information
Why?
Unity (and all game engines, really) work hard to make sure no
processor cycles are being wasted on things that aren't seen. Among
the strategies it employees is not to calculate certain things that are
not visible to the player's camera—it doesn't update them when off
screen. Joint deformations are one of these things that Unity doesn't
bother with when it can't see them. But, sometimes, Unity gets a bit
confused at what it considers on screen and thus the arms disappear
intermittently when they are right on the edge of what the camera sees.
By forcing updates even when the arms aren't on screen, we ensure that
they always stay visible.
Step 9: Create a prefab for this complete First Person Controller with
arms. First, rename First Person Controller to FPC_AegisChung. Then,
in the Project panel, choose Create>Prefab. Rename this new prefab
to the same FPC_AegisChung. Then drag the FPC_AegisChung that is
in the Hierarchy down on top of the FPC_AegisChung prefab in the
Project panel.
Why?
We've spent a lot of work getting this character set up and we'll want to
be able to use it in our other level, EntryWay. By creating the prefab, we'll
have quick access to it later when we replace the First Person Controller in
EntryWay with this one.
Conclusion
So there is still some functionality missing here. Once the game starts, the
gun comes up. This is because the arms are set to automatically play the first
animation attached to it. This means that currently, the gun is always visible
once the game starts, which we probably don't want it to be; and we don't
have any way of using the PistolFire animation yet. Don't worry, we'll return to
controlling these arms later. For now though, let's move on to being able to
have the gun actually hit stuff.
Tutorial 15.3: Firing a Gun
Fortunately, we actually have a lot of the mechanism for the gun already
created. We created it in the raycasting tutorial that build the AC_
ToolFunctionalityScript script. Open that script and take a look. We have
set up already a raycasting system that shoots a ray from the camera and
understands what it hits. In this tutorial we'll build upon that mechanism to
use raycasting to fire our gun.
Search WWH ::




Custom Search