Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Flashfast45 |
So yeah, I need help implementing Coyote Jumping but tutorials on YouTube ain’t helping at all. :(((
I’m a beginner so my code is messy :((
Can anyone tell me the code and where to put it??? (Nodes or codes )
extends KinematicBody2D
const UP = Vector2(0, -1)
const GRAVITY = 20
const MAX_SPEED = 100
const JUMP = -300
const ACCELERATION = 50
onready var animationPlayer = $AnimationPlayer
var motion = Vector2()
var is_dead = false
func _physics_process(_delta):
motion.y += GRAVITY
if is_dead == false:
if Input.is_action_pressed("ui_right"):
motion.x = min(motion.x+ACCELERATION, MAX_SPEED)
animationPlayer.play("Walk")
elif Input.is_action_pressed("ui_left"):
motion.x = max(motion.x-ACCELERATION, -MAX_SPEED)
animationPlayer.play("WalkLeft")
if Input.is_action_just_pressed("ui_quit"):
get_tree().quit()
if Input.is_action_just_released("ui_right"):
motion.x = 0
animationPlayer.play("IdleRight")
elif Input.is_action_just_released("ui_left"):
motion.x = 0
animationPlayer.play("IdleLeft")
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP
motion = move_and_slide(motion, UP)
pass
if get_slide_count() > 0:
for i in range(get_slide_count()):
if "Enemy" in get_slide_collision(i).collider.name:
dead()
func dead():
is_dead = true
motion = Vector2(0, 0)
$CollisionShape2D.disabled = true
$Timer.start()
func _on_Timer_timeout():
get_tree().change_scene(“res://Scene/Levels/World1.tscn”)
if Input.is_action_just_pressed("ui_quit"):
get_tree().quit()