Game Development Reference
In-Depth Information
yield WaitForSeconds (shotAnimation.length);
b_isShot = false;
}
private function WaitForPrepare () : IEnumerator {
_animation[shotAnimation.name].speed = shotAnimationSpeed * 2;
_animation[shotAnimation.name].wrapMode = WrapMode.ClampForever;
_animation.CrossFade(shotAnimation.name, 0.6);
yield WaitForSeconds(shotAnimation.length);
b_isPrepare = true;
}
The preceding two funcions are basically to play the aiming and shooing
animaion. Now, we are done with adding the New3PSController script.
9. Then, go back to Unity and click on the First Person Controller object in the
Hierarchy view, and go to its Inspector view; at the New 3PSController (Script) drag
both objects that we just created, as follows:
Scope UI : ScopeUI (Drag ScopeUI object here)
Rocket Launcher : RocketLauncher (Drag RocketLauncher object here)
We are done with this secion. Click Play to see the result. Now, if you hold the E key, the
scope target will appear and our character will start playing aiming animaion. If we let-click
on the mouse while holding the E key, the character will start playing the shot animaion.
However, there is no rocket coming out right now. We will create the rocket and the paricle
object in the next secion.
Objective Complete - Mini Debriefing
In this step, we just added some code to our New3PSController.js for controlling the
aiming and shot animaion as well as created the rocket launcher object and script that will
trigger when the user presses fire or aim. We also created the GUITexture object to show
the scope target graphic, which will show when the player presses E to aim and hide when
the player doesn't press E .
In the Fire() funcion, we added the rocket launcher object. We checked for the ime that
our rocket will be ired ater the shot animaion ended by checking for the reloaded ime
plus the last ime that the character was shot. We also decreased the amount of bullet when
the character clicks shot. In the next secion, we will add the rocket prefab and the paricle
object in the Fire() funcion.
 
Search WWH ::




Custom Search