Skip to content

Instantly share code, notes, and snippets.

@WolfgangSenff
Created September 29, 2022 12:39
Show Gist options
  • Save WolfgangSenff/3c8813a799965d3087f4223cf3e44aba to your computer and use it in GitHub Desktop.
Save WolfgangSenff/3c8813a799965d3087f4223cf3e44aba to your computer and use it in GitHub Desktop.
Godot RPG Movement Script Template
# 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()
@WolfgangSenff
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment