Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Splatube |
I’m a complete beginner trying to learn Godot and was trying to make a small little 2d platformer (I almost completely stole the code from heartbeasts tutorial) but with his code there was’t a way to fastfall which I tried to add and did miserably.
enter code here
extends KinematicBody2D
const UP = Vector2(0, -1)
const GRAVITY = 15
const SPEED = 200
const JUMP_HEIGHT = -500
var motion = Vector2()
func _physics_process(delta):
motion.y += GRAVITY
if Input.is_action_pressed("ui_right"):
motion.x = SPEED
if Input.is_action_pressed("ui_down"):
motion.y += 35
if Input.is_action_pressed("ui_left"):
motion.x = -SPEED
else:
motion.x = 0
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP_HEIGHT
motion = move_and_slide(motion, UP)``