This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script enables simple, 2D top-down character movement with a RigidBody2D. | |
// Ensure you have added a RigidBody2D component in the Inspector and have set its Body Type to Dynamic or Kinematic. | |
// If you're using a Dynamic Body Type, set the Gravity Scale to 0. | |
// Set the moveSpeed in the Inspector. | |
// GetAxisRaw makes the movement snappy, so the player instantly stops. If you want smoother movement, use GetAxis instead. | |
// Applying normalized to movement ensures the player doesn't move faster diagonally. | |
// If you don't multiply by Time.deltaTime, you will need to use a much smaller float for moveSpeed. | |
using UnityEngine; |
NewerOlder