Thank you for your help,
Yes, the collision is definitely not being picked up; you are right.
I have a Collisionpolygon2D for my Player and a CollisionShape2D for my Sprite as children.
Unfortunately it is still not working--and I don't an error message, the player just passes right through the Sprite. Here is the code as it looks now:
extends Sprite
func on_body_entered(area: KinematicBody2D) -> void:
if area.is_in_group("Player"):
get_tree().change_scene("res://Level_2")
And, this is the script for my Player (in case this helps solve the problem):
extends KinematicBody2D
var run_speed = 400
var jump_speed = -1100
var gravity = 2000
var velocity = Vector2()
export (int) var speed = 200
func get_input():
velocity.x = 0
var right = Input.is_action_pressed('right')
var left = Input.is_action_pressed('left')
var jump = Input.is_action_just_pressed('jump')
if is_on_floor() and jump:
velocity.y = jump_speed
if right:
velocity.x += run_speed
if left:
velocity.x -= run_speed
func _physics_process(delta):
velocity.y += gravity * delta
get_input()
velocity = move_and_slide(velocity, Vector2(0, -1))
I used a signal to link the on_body_entered
and connected it to my Sprite. Not sure if I connected it correctly.
Many thanks for any other thoughts!!