Graphics Reference
In-Depth Information
// store them internally in vert and horz so we don't have to
// access them every time we need to relay input data out
vert= Input.GetAxis( "Vertical" );
horz= Input.GetAxis( "Horizontal" );
// set up some Boolean values for up, down, left and right
Up = ( vert>0 );
Down = ( vert<0 );
Left = ( horz<0 );
Right = ( horz>0 );
// get fire/action buttons
Fire1= Input.GetButton( "Fire1" );
shouldRespawn= Input.GetButton( "Fire3" );
}
public void LateUpdate()
{
// check inputs each LateUpdate() ready for the next tick
CheckInput();
}
}
3.3 Player Manager
The player manager script acts as a simple bridge between the player controller and the
user data manager. It also creates the user data manager if one is not already attached to
the player prefab.
using UnityEngine;
using System.Collections;
public class BasePlayerManager : MonoBehavior
{
public bool didInit;
// the user manager and AI controllers are publically accessible so
// that our individual control scripts can access them easily
public BaseUserManager DataManager;
// note that we initialize on Awake in this class so that it is
// ready for other classes to access our details when they
// initialize on Start
public virtual void Awake ()
{
didInit=false;
Init();
}
public virtual void Init ()
{
// cache ref to our user manager
DataManager= gameObject.GetComponent<BaseUserManager>();
if(DataManager==null)
DataManager= gameObject.AddComponent<BaseUserManager>();
Search WWH ::




Custom Search