My personal blog

Using unity engine to do super Mario, completely self-taught, now open source

The beta can be played on Windows computers, Windows Phones and Android phones

[Note] To play on the mobile end, you need to open the virtual joystick

MarioCtrl.cs

If (Input. GetKey (KeyCode. A)) / / if (touchKey_x < 0.1 f) {transform. LocalEulerAngles = new Vector3 (0180, 0); If (Camera. Main. WorldToScreenPoint (transform. The position). X > 20) / / little Mary can't exceed sit screen {transform. Translate (Vector3. Right * runSpeed * Time.deltaTime * Mathf.Abs(touchKey_x)); } runAnim(); } the if (Input GetKey (KeyCode. D)) / / else if (touchKey_x > 0.1 f) {transform. LocalEulerAngles = new Vector3 (0, 0, 0); transform.Translate(Vector3.right * runSpeed * Time.deltaTime * Mathf.Abs(touchKey_x)); runAnim(); } if (Input.GetKeyDown(KeyCode.W) && isGround) //if (isTouchJump()&&isGround) { World.playAudio(World.jumpAudioIndex); rigidbody2D.velocity = new Vector2(0, jumpSeed); jumpAnim(); }Copy the code