// Update is called once per frame void Update() { if (particleDurationLeft > 0) { particleDurationLeft -= Time.deltaTime; if (particleDurationLeft <= 0) { flameTrail.Stop(); } } float horizontalInput = Input.GetAxis("Horizontal"); float sprintMod = 1.0f; if (Input.GetKey(KeyCode.LeftShift)) { sprintMod = 2.0f; } Move(horizontalInput * sprintMod); if (IsGrounded(groundedOffset) || IsGrounded(-groundedOffset)) { if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { Jump(); } } if (transform.position.y < deathPosY) { Die(); } CheckForJumpKill(); if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)) { rb.gravityScale = defaultGravity * gravityMultiplier; } if (Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.DownArrow)) { rb.gravityScale = defaultGravity; } if (Input.GetKeyDown(KeyCode.Escape)) { SceneManager.LoadScene("MenuScene"); } if (Input.GetKeyDown(KeyCode.Q)) { if (checkpointFlag != null) { checkpointFlag.DestroyFlag(); } Vector3 placeFlagFrom = transform.position; placeFlagFrom.y += GetComponent <BoxCollider2D>().bounds.size.y / 2; savedPosition = transform.position; checkpointFlag = (Flag)Instantiate(flagPrefab, placeFlagFrom, transform.rotation); Physics2D.IgnoreCollision(checkpointFlag.transform.GetComponent <Collider2D>(), transform.GetComponent <Collider2D>()); //checkpointFlag = GameObject.CreatePrimitive(PrimitiveType.Cube); //checkpointFlag.transform.position = savedPosition; } if (Input.GetKeyDown(KeyCode.E)) { if (checkpointFlag != null) { transform.position = savedPosition; checkpointFlag.DestroyFlag(); } } //Toggles the edition mode on and off if (Input.GetKeyDown(KeyCode.Space)) { if (inTeleportMode) { fireballIcon.SetActive(true); starIcon.SetActive(false); inTeleportMode = false; } else { fireballIcon.SetActive(false); starIcon.SetActive(true); inTeleportMode = true; } } if (Input.GetMouseButtonDown(0)) { Vector3 shootBulletFrom = transform.position; shootBulletFrom.y += GetComponent <BoxCollider2D>().bounds.size.y / 2; if (inTeleportMode) { if (teleporter != null) { teleporter.DestroyBullet(); } teleporter = (Star)Instantiate(starPrefab, shootBulletFrom, transform.rotation); Physics2D.IgnoreCollision(teleporter.transform.GetComponent <Collider2D>(), transform.GetComponent <Collider2D>()); teleporterAvailable = true; //bulletTarget = Camera.main.ScreenToWorldPoint(Input.mousePosition); //bulletTarget.z = transform.position.z; } else { shootBullet = (Fireball)Instantiate(fireballPrefab, shootBulletFrom, transform.rotation); Physics2D.IgnoreCollision(shootBullet.transform.GetComponent <Collider2D>(), transform.GetComponent <Collider2D>()); } } if (teleporterAvailable) { if (Input.GetMouseButtonDown(1)) { transform.position = teleporter.transform.position; teleporter.DestroyBullet(); teleporterAvailable = false; } } }