Generation

generate functionWed, 05 Jul 2023

Player controller for a 2d platformer in unity

public class PlayerController: MonoBehavior { /* Data */ public float movementSpeed; public float jumpForce; public float fallMultiplier = 2.5f; public float lowJumpMultiplier = 2f; public float groundCheckDistance; public float wallCheckDistance; public LayerMask groundLayer; public Transform groundCheck; public Transform wallCheck; public ParticleSystem dust; /* States */ private bool isGrounded; private bool isTouchingWall; private bool isFacingRight = true; private bool isJumping; private bool isMoving; /* Components */ private Rigidbody2D rigidbody; private Animator animator; private ParticleSystem dustClone; /* Methods */ private void Start() { rigidbody = GetComponent<Rigidbody2D>(); animator = GetComponent<Animator>(); } private void Update() { isGrounded = Physics

Want to kickstart your project?Use the new AI Studio to create your code