Godot Version
`4.3
Here is my collision problem:
Here are my player and enemy scripts:
Player
extends CharacterBody2D
var move_speed :float = 100
var jump_force :float = 200
var gravity :float = 500
func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta
velocity.x = 0
if Input.is_key_pressed(KEY_LEFT):
velocity.x -= move_speed
if Input.is_key_pressed(KEY_RIGHT):
velocity.x += move_speed
if Input.is_key_pressed(KEY_SPACE) and is_on_floor():
velocity.y = -jump_force
move_and_slide()
if global_position.y > 100:
game_over()
func game_over():
get_tree().reload_current_scene()
Enemy
extends Area2D
@export var move_speed : float = 30.0
@export var move_dir : Vector2
var start_pos : Vector2
var target_pos : Vector2
# Called when the node enters the scene tree for the first time.
func _ready():
start_pos = global_position
target_pos = start_pos + move_dir
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
global_position = global_position.move_toward(target_pos, move_speed * delta)
if global_position == target_pos:
if global_position == start_pos:
target_pos = start_pos + move_dir
else:
target_pos = start_pos
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("Player"):
print("Collision Working")
body.game_over()
Here is a screenshot of my Godot Interface:
I am having the following repeated errors(120) in my debugger:
E 0:00:02:0074 create_tile: Cannot create tile. The tile is outside the texture or tiles are already present in the space the tile would cover.
<C++ Error> Condition “!room_for_tile” is true.
<C++ Source> scene/resources/2d/tile_set.cpp:4963 @ create_tile()
E 0:00:02:0074 has_alternative_tile: The TileSetAtlasSource atlas has no tile at (20, 0).
<C++ Error> Condition “!tiles.has(p_atlas_coords)” is true. Returning: false
<C++ Source> scene/resources/2d/tile_set.cpp:5400 @ has_alternative_tile()
E 0:00:02:0074 create_alternative_tile: TileSetAtlasSource has no tile at (20, 0).
<C++ Error> Condition “!tiles.has(p_atlas_coords)” is true. Returning: TileSetSource::INVALID_TILE_ALTERNATIVE
<C++ Source> scene/resources/2d/tile_set.cpp:5348 @ create_alternative_tile()
can anyone help?