Godot Version
4.3
Question
Hello, im fairly new to godot and I am trying to create scene transitions between different levels, However the area2d is not detecting the player when they collide and so the scenes arent transitioning. I have redon my collision layers and i am fairly sure they shoudd work however the area2d which is tryng to detect the player isnt. Any help would be greatly apprceiated.
extends Node2D
@onready var pauseMenu = $"Main/Entities/Player/Pause menu"
var paused = false
func _ready():
$Fade/AnimationPlayer.play("Fade_out")
func _process(delta):
if Input.is_action_just_pressed("pause"):
pausemenu()
func pausemenu():
if paused:
pauseMenu.hide()
get_tree().paused = false
else:
pauseMenu.show()
get_tree().paused = true
paused = !paused
func _on_scene_transition_detection_body_entered(body : Node2D) -> void:
if body is player:
print(body)
this is the level code with the transition signal, i havent implemnetd the actual scene transition as the body sint being printed so it wouldnt work
extends CharacterBody2D
class_name player
@onready var animation_tree : AnimationTree = $AnimationTree
@onready var sprite : Sprite2D = $Sprite2D
@onready var state_machine : CharacterStateMachine = $characterstatemachine
@export_group("move")
@export var speed: int = 200
@export var acceleration := 700
@export var friction := 10000
var direction := Vector2.ZERO
var can_move := true
var dash := false
@export_range(0.1,2) var dash_cooldown := 0.5
var gamepad_active := true
@export_group("jump")
@export var jump_strength := 300
@export var gravity := 600
@export var terimnal_velocity := 500
var jump := false
var faster_fall := false
var gravity_multiplier := 1
func _ready():
$Timers/DashCooldown.wait_time = dash_cooldown
animation_tree.active = true
func _process(delta):
apply_gravity(delta)
if can_move:
get_input()
apply_movement(delta,state_machine)
update_animation()
update_facing_direction()
func update_animation():
animation_tree.set("parameters/move/blend_position",direction.x)
func update_facing_direction():
if direction.x > 0:
sprite.flip_h = false
elif direction.x < 0:
sprite.flip_h = true
func get_input():
#horizontal movement
direction.x = Input.get_axis("Left","Right")
#jump
if Input.is_action_just_pressed("Jump"):
if is_on_floor() or $Timers/Coyote.time_left:
jump = true
if velocity.y > 0 and not is_on_floor():
$Timers/JumpBuffer.start()
if Input.is_action_just_released("Jump") and not is_on_floor() and velocity.y < 0:
faster_fall = true
#dash
if Input.is_action_just_pressed("dash") and velocity.x and not $Timers/DashCooldown.time_left:
dash = true
$Timers/DashCooldown.start()
var aim_input_gamepad = Input.get_vector("Left","Right","up","down")
#if aim_input_gamepad.length() > 0.5:
#aim_direction = Vector2(round(aim_input_gamepad.x),round(aim_input_gamepad.y))
func apply_movement(delta,state_machine):
#left/right movement
if direction.x && state_machine.check_if_can_move():
velocity.x = move_toward(velocity.x, direction.x * speed, acceleration * delta)
else:
#introduces friction in order to stop player if there is no input
velocity.x = move_toward(velocity.x, 0, friction * delta)
#jump
if jump or $Timers/JumpBuffer.time_left and is_on_floor():
velocity.y = -jump_strength
jump = false
faster_fall = false
var on_floor = is_on_floor()
move_and_slide()
if on_floor and not is_on_floor() and velocity.y >= 0:
$Timers/Coyote.start()
#dash
if dash:
dash = false
var dash_tween = create_tween()
dash_tween.tween_property(self, 'velocity:x',velocity.x + direction.x * 600,0.3)
dash_tween.connect("finished",on_dash_finish)
gravity_multiplier = 0
func apply_gravity(delta):
velocity.y += gravity * delta
velocity.y = velocity.y / 2 if faster_fall and velocity.y < 0 else velocity.y
velocity.y = velocity.y * gravity_multiplier
velocity.y = min(velocity.y, terimnal_velocity)
func on_dash_finish():
velocity.x = move_toward(velocity.x,0,500)
gravity_multiplier = 1
this is the player script, the class name is player so it shoudl be working
I can attach anyore dteials if needed, Thank you