Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ПЕТР |
extends KinematicBody2D
var speed = 15
var jumpForce = 100
var gravity = 400
var vel = Vector2()
onready var imageKUNDEL = get_node("Кундель-transformed")
func _physics_process(delta):
if Input.is_action_pressed("kun_left"):
vel.x -= speed
elif Input.is_action_pressed("kun_right"):
vel.x += speed
vel.y += gravity * delta
if Input.is_action_pressed("kun_jump") and is_on_floor():
vel.y -= jumpForce
vel = move_and_slide(vel, Vector2.UP)
if vel.x < 0:
imageKUNDEL.flip_h = true
elif vel.x > 0:
imageKUNDEL.flip_h = false
Edited to fix code formatting. Also, Google translated the title into English, as this is an English speaking forum and you’ll likely get more input that way…
jgodfrey | 2023-04-29 22:07