Raycast2D not functioning?
But the issue is that the Raycast2D's aren't functioning at all, and since the Raycasts are vital to determining whether the player's on the ground or not in the tutorial, not only do I end up being able to jump infinitely, but the player character is stuck in the jump animation. Here's my current code, which isn't much different from the video:
extends KinematicBody2D const UP = Vector2(0, -1) const SLOPE_STOP = 64 var velocity = Vector2() var move_speed = 5 * 96 var gravity = 800 var jump_velocity = -700 var is_grounded onready var raycasts = $Raycasts onready var anim_player = $Body/AnimationPlayer func _physics_process(delta): _get_input() velocity.y += gravity * delta velocity = move_and_slide(velocity, UP, SLOPE_STOP) is_grounded = _check_is_grounded() _assign_animation() func _input(event): if event.is_action_pressed("lt_up") && is_grounded: velocity.y = jump_velocity func _get_input(): var move_direction = -int(Input.is_action_pressed("lt_left")) + int(Input.is_action_pressed("lt_right")) velocity.x = lerp(velocity.x, move_speed * move_direction, 0.2) if move_direction != 0: $Body.scale.x = move_direction func _check_is_grounded(): for raycast in raycasts.get_children(): if raycast.is_colliding(): return true return false func _assign_animation(): var anim = "Idle" if is_grounded: anim = "Jump" elif velocity.x != 0: anim = "Run" if anim_player.assigned_animation != anim: anim_player.play(anim)
Is there anything I'm doing wrong here? And yes, I made sure that the Raycasts were enabled beforehand.