0 votes

Forgive me if this is a very simple question!

I'm trying to make an Area2D collide with a ball (with a rigidbody2d attached).
I'm instantiating a line of these balls from another Node (named Line) through code but the signal isn't being triggered.
Both have CollisionShape2D's attached

If I add the ball in not through code, the signal kicks off.

I can't find anything in the documentation to help with this?
Sorry if this isn't enough info, if you need anymore happy to provide it!

Godot version v3.4.stable.official [206ba70f4]
in Engine by (19 points)

1 Answer

+1 vote
Best answer

perhaps You didn't set collision layer of new area ? Or monitoring to true ?

Use REMOTE tab to examine your instanced Area. You can see it in top left corner of editor, right above scene tree. When You run project new option will appear there : Local/Remote. When You choose remote, You will see scene tree of your running project, with all areas instanced in code in realtime. Find out what is different about these areas and the ones You create in editor.

by (7,925 points)
selected by

Thanks for answering!
I did more experimentation and it worked when I switched from RigidBody2D to KinematicBody2D?

Not 100% sure why this fixed it (assuming because I was updating the position directly rather than the physics engine, the collision wasn't being detected?).

Even when updating position manually collision will eventually be reported when bodies overlap, only their collision behavior will be broken. Kinematic body has less restrictive collision defaults. You can check if can_sleep was on with your rigid bodies.

can_sleep was on
When set to off it seems like it triggers the collision!

Thank you so much!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.