super mario bros
The developer has not uploaded a asset pack yet...
using UnityEngine; public class PlayerController : MonoBehaviour { public float moveSpeed = 5f; public float jumpForce = 5f; private bool isJumping = false; private Rigidbody2D rb; private Animator animator; private void Start() { rb = GetComponent<rigidbody2d>(); animator = GetComponent<animator>(); } private void Update() { float moveX = Input.GetAxis("Horizontal"); rb.velocity = new Vector2(moveX * moveSpeed, rb.velocity.y); animator.SetFloat("Speed", Mathf.Abs(moveX)); if (Input.GetButtonDown("Jump") && !isJumping) { rb.AddForce(new Vector2(0f, jumpForce), ForceMode2D.Impulse); isJumping = true; } } private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Ground")) { isJumping = false; } } } </animator></rigidbody2d>
Status | Released |
Category | Assets |
Author | basicgaming |
Tags | 1-bit |
Leave a comment
Log in with itch.io to leave a comment.