0 votes

I'm trying to set a collision, I'll try to be as clear as possible.

As of now I have my character, moves in 4 directions, and I have an "enemy" that goes up and down in the level.

◘ ○○○○○○○ ↑ ○○○○○○○○○○ ◘
◘ ○○○○○○○ En ○○○○○○○○○ ◘
◘ ○○○○○○○ ↓ ○○○○○○○○○○ ◘
◘ ○○○○○○○○○○○ Char ○○○ ◘

Both Kinematics 2D, with direct child CollisionShape. Now I want to say (the script is in the character):

"if (my collisionshape overlaps with another collisionshape) do something"

That "do something" would be relocating my character, that part is handled. But I'm having problems getting the collision. So far I haven't been able to use "is_colliding" properly.

Thanks in advance.

in Engine by (23 points)


Do you have set_contact_monitor(true) and set_max_contacts_reported(>0) ? it's a common problem :)

1 Answer

0 votes

The node CollisionShape2D is only an editor helper to make drawing shape resources more easy, it won't report anything by itself.

If you want to detect collisions with a KinematicBody, you need to use the method move followed by is_colliding and other methods that give you collision information.

Read the official tutorials about KinematicBody2D http://docs.godotengine.org/en/stable/tutorials/2d/kinematic_character_2d.html

And look at both demos, the one of Kinematic Collision (basic) and Kinematic Character (more advanced).

by (7,934 points)
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.