Area 3d Doesn't work

Godot Version



So I am trying to make a trigger that teleports you to the next map. However, it doesn’t work.
This is my code:

func _on_area_3d_3_area_entered():

It sounds like your function isn’t being called because it isn’t hooked up to the area_entered signal properly. Double check that your signal is invoking the correct function. You should see a connection icon in the left margin.


If you have connected via code - look there too.

1 Like

Have that too

Aloa mrnull,

we neither know what your map_3 scene looks like nor how you set things up.

Provide a minimal non working project. Else the rest is just guessing blindly.

Kind regards,

Okay let me give you the scene file

Okay, use the scene gamemap2
Sorry about the file organization and all that, it’s a mess.

You shouldn’t send almost a gigabyte of project files, especially with 4k 60fps footage, to get help on connecting a signal. :pensive:

So the thing is, your player is a CharacterBody3D, so it’s a “body” rather than an “area”, so the correct signal to wire from your Area3D is body_entered(body: Node3D) rather than area_entered(area: Area3D).

This would work nicely is you weren’t trying to change the scene in place.
As you can see from in the debugger errors, you are not allowed to remove physics objects in a physics callback (this is because changing the scene would unload the whole scene tree before loading new map in).

But you can memorize you want to change map instead and do it on the next update like so:

var trigger_next_map : bool = false

func _physics_process():
    if trigger_next_map:
    #Character movement  ...

func _on_area_3d_body_entered(body):
	trigger_next_map = true

It works, but CSG looks like its in the way and might trigger you area preemptively before your player reaches it. You can set specific collision layer and mask with your area and player to fix the bug.

And I can not recommend enough to deal with that kind of stuff with “States”, as in:

var current_state : State : set set_state

# Set states
func _ready():
    current_state = State.PLAYING
func _input(event):
    if event.is_action_pressed("Escape") and current_state == State.PLAYING:
        current_state = State.PAUSED
func _on_aread_3d_body_entered(_body):
    current_state = State.CLEARED    

# Deal with states
func set_state(new_state:State):
    if current_state == State.PAUSED and new_state == State.CLEARED:
        print("It's forbidden to clear level during pause")
        current_state = new_state

    # Change map if cleared
    if current_state == State.CLEARED:

Keep up the good work!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.