A downloadable asset pack

Player Movement 2D

A simple and flexible 2D movement system for Unity games, supporting physics-based movement via Rigidbody2D. Perfect for both 2D platformers and 2D top-down games, this script offers smooth player controls with optional jumping (including double jump) and dashing capabilities.

demo

Features

  • Camera follow system: smoothly follow player.
  • Physics-Based Movement: Utilizes Rigidbody2D for reliable physics interactions.
  • Horizontal & Vertical Movement: Toggle movement directions to suit your game design.
  • Jumping: Enable single or double jumps with customizable jump force and gravity.
  • Ground Detection: Raycast-based system to ensure accurate jump logic (with optional debug visualization).
  • Dashing: Temporarily boost movement speed with adjustable dash speed, duration, and key binding.

Setup Instructions

1️⃣ Adding the Script

  • Attach the PlayerMovement2D script to your player GameObject or use the premade player (found in prefabs folder).
  • The script automatically adds a Rigidbody2D and requires a Collider2D (add any type of collider 2d you want. Unity won't let you put the code unless you put a collider)

2️⃣ Configuring Movement

  • Enable or disable horizontal/vertical movement as needed.
  • Set your desired player speed.

3️⃣ Setting Up Jumping

  • Enable jumpNeeded for basic jumping or dubbleJumpNeeded for double jump functionality.
  • Configure the jumpForce, gravityScale, and groundDetectorLength to fine-tune jump behavior.
  • Assign the proper Ground Layer to detect when the player is on solid ground.
  • Optionally, enable "Draw Jump Detector" to visualize the raycast in the Unity Editor.
  • Set the jump key (default is Space).

4️⃣ Enabling Dashing

  • Check dashEnabled to allow the dash feature.
  • Set the dashSpeed and dashDuration to control dash performance.
  • Assign a dash key (default is Left Shift)

5️⃣ Camera

  • If you are using the player prefab remove the normal camera and the smooth camera should work
  • You can also add this effect to any camera by adding the CameraMovement script.
    • after adding the script you can put your player as target
    • you can also add offset and change the speed of the camera. 

Usage

  • Move: Use the arrow keys or WASD to control your player.
  • Jump: Press Space (or your chosen jump key) to jump, if enabled.
  • Dash: Press Left Shift (or your chosen dash key) to dash, if enabled.

Requirements

  • Unity Engine 6000+ (Tested with version 6000.0.35f1)
  • Basic knowledge of c# and unity components

License

MIT License Copyright (c) 2025 Sillylix Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

🤖 AI Assistance

This description was refined with the help of AI to enhance clarity.
some of the code and comments was made with AI (github co-pilot)

Download

Download
PlayerMovement.unitypackage 37 kB

Leave a comment

Log in with itch.io to leave a comment.