void FixedUpdate() { if (lockMovement) { return; } if (state == (int)states.normal) { float hor = Input.GetAxis("Horizontal2"); //anim.SetFloat("Speed", Mathf.Abs(hor)); int invisibleWall = FollowChracter.WallRobo(); if (!(hor < 0 && invisibleWall < 0) && !(hor > 0 && invisibleWall > 0)) { rb2d.velocity = new Vector2(hor * maxSpeed, rb2d.velocity.y); } else { rb2d.velocity = new Vector2(0, rb2d.velocity.y); } //isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.15f, whatIsGround); //anim.SetBool("isGrounded", isGrounded); if ((hor > 0 && !lookingRight) || (hor < 0 && lookingRight)) { Flip(); } if (jump) { rb2d.AddForce(new Vector2(0, jumpForce)); jump = false; } } }
void Update() { if (activated) { if (counter == 0) { RobotControllerLucas.lockMovementRobo = true; PlayerController2D.lockMovementProf = true; FollowChracter.lockCamera(); FollowChracter.setElevatorTransition(); } else if (counter > 30 && counter < 85) { Door.transform.localScale += new Vector3(0, 0.125f, 0); Door.transform.Translate(0, -0.03125f / 2f, 0); } else if (counter == 110) { camInit = Cam.transform.position; Vector2 CamFocus2D = CamFocus.transform.position; stepCamTransit = (CamFocus2D - camInit) / 60f; } else if (counter > 110 && counter <= 170) { Vector2 newCamPosition = (Vector2)Cam.transform.position + stepCamTransit; FollowChracter.setXY(newCamPosition); } else if (counter > 180 && counter < 330) { Vector3 jurney = new Vector3(0, 0.1f, 0); if (jiggle == 3) { jurney.y = 0.15f; } if (jiggle == 4) { jurney.y = 0.05f; jiggle = -1; } jiggle++; Elevator.transform.Translate(jurney); Prof.transform.Translate(jurney); Robo.transform.Translate(jurney); if (counter <= 270) { FollowChracter.setXY((Vector2)Cam.transform.position + new Vector2(0, 0.1f)); } } else if (counter > 350 && counter <= 390) { FadeOut.color += new Color(0, 0, 0, 0.025f); } else if (counter == 391) { if (level == 1) { SceneManager.LoadScene("Level2", LoadSceneMode.Single); } else { SceneManager.LoadScene("Level1", LoadSceneMode.Single); } } counter++; } }
void FixedUpdate() { if (lockMovement) { return; } //Rechts/Links Bewegung durch unsichtbare Wand begrenzen float moveHorizontal = Input.GetAxis("Horizontal"); int invisibleWall = FollowChracter.WallProf(); if (!(moveHorizontal < 0 && invisibleWall < 0) && !(moveHorizontal > 0 && invisibleWall > 0)) { gameObject.transform.Translate(moveHorizontal * speed, 0, 0.0f); } //Springen und Landen //Spieler-Eingabe "Jump" if (Input.GetButtonDown("Jump")) { if (jumpingMode == (int)Jump_modes.standing) { jumpingMode = (int)Jump_modes.jumping; jumpCount = 0; } else if (jumpingMode == (int)Jump_modes.falling) { storedJump = true; } } if (jumpingMode == (int)Jump_modes.standing && storedJump) { storedJump = false; jumpingMode = (int)Jump_modes.jumping; jumpCount = 0; } //Jump-Translation if (jumpingMode == (int)Jump_modes.jumping) { gameObject.transform.Translate(0, jumpHeight, 0.0f); jumpCount++; if (jumpCount >= jumpCountMax) { jumpCount = 0; jumpingMode = (int)Jump_modes.falling; } } //Update des Spring-Modus if (jumpingMode == (int)Jump_modes.jumping && Prof.transform.position.y <= profY_old) { jumpingMode = (int)Jump_modes.falling; } else if (jumpingMode == (int)Jump_modes.falling && Prof.transform.position.y >= profY_old) { jumpingMode = (int)Jump_modes.standing; } profY_old = Prof.transform.position.y; //Prof. in Gehrichtung drehen if (moveHorizontal < 0 && faceRight) { transform.localScale = new Vector2(-direction, transform.localScale.y); faceRight = false; } else if (moveHorizontal > 0 && !faceRight) { transform.localScale = new Vector2(direction, transform.localScale.y); faceRight = true; } }