public static void CreatePlayer() { CreatePlayerForm(); MeshUpdate.UpdatePlayer(); CreatePlayerFields(); }
/// <summary> /// Scale the player over time, starting quick and becoming slow. Also update the player width(!). Used for when the player releases the play-button. /// </summary> public IEnumerator DampedScale(float targetScale, float timeToStart = 0) { yield return(new WaitForSeconds(timeToStart)); float maxTime = 2.2f; float timer = 0; Vector3 maxScale = new Vector3(targetScale, targetScale, 1); while (timer < maxTime) { Vector3 scaleSpeed = (maxScale - this.transform.localScale) * bt_scaleDamp * DeltaTime; this.transform.localScale += scaleSpeed; MeshUpdate.UpdatePlayer(); timer += Time.deltaTime; yield return(null); } }
/// <summary> /// Perform rotation once. Damped by bt_rotationDamp. Update player mesh (!!). /// </summary> private void RotateToTarget(Vector3 targetPos) { // 1. Rotate Vector3 targetVec = targetPos - this.transform.position; Vector3 curVec = OuterVertices[0] - this.transform.position; float nextRot = Vector2.SignedAngle(curVec, targetVec) * bt_rotationDamp * DeltaTime; this.transform.eulerAngles += new Vector3(this.transform.eulerAngles.x, this.transform.eulerAngles.y, nextRot); // Hack (gegen 180° & 60° Winkel) if ((Mathf.Abs(this.transform.eulerAngles.z) > 180f - 0.1f && Mathf.Abs(this.transform.eulerAngles.z) < 180f + 0.1f) || Mathf.Abs(this.transform.eulerAngles.z) > 60f - 0.1f && Mathf.Abs(this.transform.eulerAngles.z) < 60f + 0.1f) { this.transform.eulerAngles += new Vector3(0, 0, 0.1f); } // 2. Update player meshes MeshUpdate.UpdatePlayer(); }