0 votes

heyy guys beginner here, and a long question sorry. I want to connect a kinebody2d(player.tscn) to another kinebody2d(block.tscn), where if it enters the area2d area around the block by pressing "enter" it connects to it like a magnet, but can still control the player movement with the block attach, and then disconnects from it when you hit "enter" again. Thnx in advance

Godot version V.3.4.4
in Engine by (13 points)

1 Answer

0 votes

Aside from the functonality of what you want to achieve, I suppose you are asking how to connect signals? and how to detect being in an area2d? and how to trigger the send signal when pressing enter? Try to be more specefic with what is that you are having problems.

You can connect signals in the editor or by code, you can read about it in the docs, and ask here again if you have problems with it. you would have to conect a custom signal between the player and the block (to inform the block that entere was pressed, so the block can engage and disengage).

There are many ways to know if you are inside an especific area. For example triggering signals of body entered and body exited and saving that info on a var on the player.

Once you have that info on the player, just check for it with an if statement when pressing enter, and if true send the signal to the block.

First manage these 3 steps and check if the whole thing is working, and then move to what you want to do with the actual block.

by (418 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.