Godot Version
Using Godot Web Editor 4.6.2
Question
Hello. I’m currently making a game with tile-based movement. Right now, I’m trying to make collectables. All you have to do, is step on the same space as the collectable to pick it up.
I’m using Area2D signals for pickups, but for some reason nothing is being detected, despite being on the same collision layer. The code for both the player and the collectable is down below. Please help me fix.
Player:
extends CharacterBody2D
const grid = 16
@onready var down: RayCast2D = $down
@onready var up: RayCast2D = $up
@onready var left: RayCast2D = $left
@onready var right: RayCast2D = $right
func _process(delta: float) -> void:
pass
# Grid-based movement lol
if Input.is_action_just_pressed("up") and not up.is_colliding():
position += Vector2(0, -grid)
if Input.is_action_just_pressed("down") and not down.is_colliding():
position += Vector2(0, grid)
if Input.is_action_just_pressed("left") and not left.is_colliding():
position += Vector2(-grid, 0)
if Input.is_action_just_pressed("right") and not right.is_colliding():
position += Vector2(grid, 0)
Collectable:
extends StaticBody2D
@onready var player: CharacterBody2D = $"../Player"
func _on_coin_body_entered(body):
queue_free()