void FixedUpdate() { if (pause) { } else { Timer(); if (timer == 2) { data.Flush(); } if (timer <= 0) { timer_.SetActive(false); float speed = 0f; float Thrust = 0f; slider.value = data.grasping_force; if (data.grasping_force < 20) { float prop_size = (data.grasping_force * 0.05f); transform.localScale = new Vector3(prop_size + .5f, prop_size + .75f, 0); } if (data.grasping_force >= 20 && GM.Levels[2].activeInHierarchy) { particle.transform.position = transform.position; rb.velocity = new Vector3(0f, 0f, 0f); particle.SetActive(true); player.SetActive(false); exp = particle.GetComponent <ParticleSystem>(); exp.Play(); GM.Invoke("GameOver", 1); } if ((data.Jump || Input.GetKeyDown("space")) && !InAir) { Thrust = thrust; } else { Thrust = rb.velocity.y; } if (!InAir) { speed = Speed; } else { speed = rb.velocity.x; } rb.velocity = new Vector2(speed, Thrust); if (rb.position.y < -8) { FindObjectOfType <Game_Manager>().GameOver(); } } } /*// Cast a ray straight down. * RaycastHit2D hit = Physics2D.Raycast(transform.position - new Vector3(0f, transform.localScale.y, 0f), -Vector2.up, transform.localScale.y/2.0f); * * // If it hits something... * if (hit.collider != null) * { * float distance = Mathf.Abs(hit.point.y - transform.position.y); * if (distance < transform.position.y) * { * // Calculate the distance from the surface and the "error" relative * // to the floating height. * Debug.DrawRay(transform.position - new Vector3(0f, transform.localScale.y, 0f), Vector3.down * distance, Color.yellow); * Debug.Log("Did Hit"); * } * * } * else * { * Debug.DrawRay(transform.position - new Vector3(0f, transform.localScale.y, 0f), transform.TransformDirection(Vector3.down) * (transform.localScale.y / 2.0f), Color.red); * Debug.Log("Did Not Hit"); * }*/ }