Graphics Reference
In-Depth Information
if(!_animation)
Debug.Log("The character you would like to control doesn't
have animations. Moving her might look weird.");
Animations for idle, walking, running, and jumping should be referenced by the
Inspector window on the character for them to work with this script. If any of them are
missing, however, we don't want it to stop working altogether; a message to report what is
missing will be written to the debug window instead via Debug.Log:
if(!idleAnimation) {
_animation = null;
Debug.Log("No idle animation found. Turning off
animations.");
}
if(!walkAnimation) {
_animation = null;
Debug.Log("No walk animation found. Turning off
animations.");
}
Init() caches references to the characters rigidbody, gameObject, and transform
before grabbing references to some required scripts. To work within the player structure,
Keyboard_Input.cs is used to provide input from the player to move the character around.
BasePlayerManager.cs is also referenced in the Init() function, and although this script
does not use it directly, it does store a reference to the player manager for other scripts to
access:
public virtual void Start ()
{
Init ();
}
public virtual void Init ()
{
// cache the usual suspects
myBody= rigidbody;
myGO= gameObject;
myTransform= transform;
// add default keyboard input
default_input= myGO.AddComponent<Keyboard_Input>();
// cache a reference to the player controller
myPlayerController= myGO.GetComponent<BasePlayerManager>();
if(myPlayerController!=null)
myPlayerController.Init();
}
The SetUserInput() function is used to set canControl, which is used to check whether
user input should be disabled or not:
public void SetUserInput( bool setInput )
{
canControl= setInput;
}
Search WWH ::




Custom Search