// Use this for initialization void Start() { control = (MoveKinematic)gameObject.AddComponent ("MoveKinematic"); controller = new PController (control); if (drawLines) { lines = gameObject.AddComponent<LineRenderer> (); lines.SetWidth (0.1f, 0.1f); lines.material = new Material(Shader.Find("Unlit/Texture")); lines.castShadows = false; lines.receiveShadows = false; lines.SetColors (Color.white, Color.white); } }
// Update is called once per frame void Update() { control = (MoveKinematic)GetComponent("MoveKinematic"); float vx = 0; float vz = 0; bool up = Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W); bool down = Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S); bool left = Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A); bool right = Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D); if (up) vz = v0; if (down) vz = -v0; if (left) vx = -v0; if (right) vx = v0; control.applyMotion (vx, vz); }