Created
September 29, 2022 12:39
-
-
Save WolfgangSenff/3c8813a799965d3087f4223cf3e44aba to your computer and use it in GitHub Desktop.
Godot RPG Movement Script Template
This file contains hidden or 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
# meta-description: Classic movement for RPG or top-down games that do not apply gravity | |
# meta-name: RPG movement | |
# meta-default: true | |
# meta-space-indent: 4 | |
extends _BASE_ | |
const SPEED = 450.0 | |
const FRICTION = 1000.0 | |
func _physics_process(delta: float) -> void: | |
# Get the input direction and handle the movement/deceleration. | |
# As good practice, you should replace UI actions with custom gameplay actions. | |
var direction := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") | |
if direction: | |
velocity = direction * SPEED | |
else: | |
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) | |
move_and_slide() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://docs.godotengine.org/en/latest/tutorials/scripting/creating_script_templates.html for details.