// Update is called once per frame public override void Update() { if (state == State.Casting) { playerState = PlayerState.Slowed; } else if (isBusy()) { playerState = PlayerState.Busy; } else { playerState = PlayerState.Normal; } if (playerState != PlayerState.Busy) { Vector3 v = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); v *= (Input.GetKey(KeyCode.LeftShift) || playerState == PlayerState.Slowed) ? moveSpeed / 2 : moveSpeed; float lerp = 1 - Mathf.Exp(-Time.deltaTime * 10); if (v != Vector3.zero) { controller.Move(transform.TransformVector(v) * Time.deltaTime); anim.SetFloat("Speed", Mathf.Lerp(anim.GetFloat("Speed"), v.magnitude / 6f, lerp)); } else { anim.SetFloat("Speed", Mathf.Lerp(anim.GetFloat("Speed"), 0, lerp)); } float r = 0; if (LeapControl.isTracked) { Vector3 handPosition = LeapControl.GetTargetingPositionOnScreen(); if (handPosition.x < rotateAreaWidth) { r = -(1 - handPosition.x / rotateAreaWidth); } else if (handPosition.x > Screen.width - rotateAreaWidth) { r = 1 - (Screen.width - handPosition.x) / rotateAreaWidth; } } r += Input.GetAxis("Rotational"); transform.rotation = Quaternion.AngleAxis(r * maxRotationSpeed * Time.deltaTime, Vector3.up) * transform.rotation; } base.Update(); }
// Use this for initialization void Start() { control = this; UpdateTrackedSpace(); }
// Use this for initialization void Start() { control = this; }