Graphics Reference
In-Depth Information
11. 6 Player Controller
Lazer Blast Survival uses an animated human player model from the Unity3d Angry Bots
tutorial, included with Unity. It uses a class that derives from the top-down controller
script shown in Chapter 5, adding custom game-specific scripting to it and a separate class
to take care of animating the character model.
The player class Player_LBS derives from the controller script BaseTopDown.cs, a
modified version of the third-person controller script included with Unity that uses Unity's
built-in character controller for physics. BaseTopDown.cs is detailed in full in Chapter 5
(Building Player Movement Controllers).
Player_LBS.cs looks like this:
using UnityEngine;
using System.Collections;
public class Player_LBS : BaseTopDown
{
private bool isInvulnerable;
private bool isRespawning;
public BasePlayerManager myPlayerManager;
public BaseUserManager myDataManager;
public bool godMode =false;
public GameObject theMeshGO;
public Standard_SlotWeaponController weaponControl;
public bool canFire;
public bool isFinished;
public override void Init ()
{
base.Init();
// do god mode, if needed)
if(!godMode)
{
MakeVulnerable();
} else {
MakeInvulnerable();
}
// start out with no control from the player
canControl=false;
// get a ref to the weapon controller
weaponControl=
myGO.GetComponent<Standard_SlotWeaponController>();
// if a player manager is not set in the editor, let's try
// to find one
if(myPlayerManager==null)
myPlayerManager=
myGO.GetComponent<BasePlayerManager>();
Search WWH ::




Custom Search