Godot Versionv4.6.1
Question
I am a noob and I just followed some random tutorial on youtube and changed a bit of stuff. Here are the codes for both the killzone and the player
extends Area2D
func _on_body_entered(body) -> void:
if body.name == "Player":
body.respawn()
monitoring = true
extends CharacterBody2D
class_name Player
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
func respwan():
self.global_position == Vector2(1,0)
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_pressed("ui_right"):
$AnimatedSprite2D.play("walk")
if Input.is_action_pressed("ui_left"):
$AnimatedSprite2D.play("walkleft")
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
if Input.is_action_pressed("ui_right"):
$AnimatedSprite2D.play("walk")
if Input.is_action_pressed("ui_left"):
$AnimatedSprite2D.play("walkleft")
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
$AnimatedSprite2D.play("idle")
move_and_slide()
The CharacterBody just kinda falls down into the void and completely ignores the collision of the area2d
