CollisionShape2D not detecting other Area2d

Godot Version

Godot 4.2.1


Hi everyone ! I’m new to Godot and having trouble with collisionShape2D.

I have this Area2D scenes in which I add as a child a CollisionShape2D through the script. However, the Area2D doesn’t detect anything if I instance it using new(). Yet, it is working well if I load the scene first then instantiate it.

So, what I’d be doing is :

var good_exp = load(“Test”).instantiate()

var bad_exp =

In the first case, good_exp will detect every other area2D as it is supposed to do. But in case2 it won’t. Why is that ?

this is instantiating a scene

this is creating a new Object of (class_name) Test

1 Like

As @zdrmlpzdrmlp said, you should only ever be using instantiate() to create scenes.

.new() is for non-scene objects.

This is because a scene consists of 2 things - a tscn file that stores data about nodes in the scene, and .gd file that attaches to scene events. If you just use .new() on a scene’s .gd file, it won’t be attached to any scene.

As far as I understand it, anyway :sweat_smile: