May 2018
Beginner
492 pages
11h 53m
English
The next requirement is to start and stop moving by clicking an input button. We'll look for a button press using the logical "Fire1" button. If you want to use a different button, or if you're targeting a platform that does not have a mapping to "Fire1" please refer to Chapter 5, Handy Interactables, under the topic Basic button input.
Modify the GlideLocomotion script as follows:
using UnityEngine;
public class GlideLocomotion : MonoBehaviour {
public float velocity = 0.7f;
private CharacterController controller; private bool isWalking = false;
void Start() {
controller = GetComponent<CharacterController> ();
}
void Update () {
if (Input.GetButtonDown("Fire1")) isWalking = true; else if (Input.GetButtonUp("Fire1")) ...Read now
Unlock full access