Can't Disapper "Blocks"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By keito940
:warning: Old Version Published before Godot 3 was released.

I am making a breakout,
Thanks to all of your questions, we have reached the point of changing things called contact monitors.
However, even if the ball collides, the block does not disappear.

Briefly explaining the mechanism of the game,
KinematicBody 2D called “Blocks”
It collapses when it collides with RigidBody 2D called “Ball”.

func _fixed_process(delta):
	var bodies = get_colliding_bodies()

	for body in bodies:
		if body.is_in_group("Blocks"):
			body.queue_free()

try adding a Print line in order to make sure you have something that activate the if statement

rustyStriker | 2017-10-06 09:21

Make sure the “body” is the root of the brick, because otherwise you could destroy the body but not the sprite. Also obviously make sure all your brick bodies are in the “Blocks” group.

Zylann | 2017-10-06 12:51

Make sure the “body” is the root of the brick, because otherwise you could destroy the body but not the sprite. Also obviously make sure all your brick bodies are in the “Blocks” group.

I am that makes “Blocks” Group , but even if you hit the ball,
The block does not disappear.
I also checked the code firmly, but I do not know the cause.

try adding a Print line in order to make sure you have something that activate the if statement

Try Now.

for body in bodies:
	if body.is_in_group("Blocks"):
		print("Deleted")
		body.queue_free()
	else:
		print("Can't Deleted")

keito940 | 2017-10-07 07:28

Even if you hit a block against a ball at that time,
“Can not Deleted” appears and the block does not disappear.
Also, even if you hit a paddle, “Can not Deleted” comes out (specification).

keito940 | 2017-10-13 08:33

try making a simple scene with one block to destroy and a ball(or whatever) going towards the block and insert the ball the above scripts without the if statement( aka if collides then disappear ) if the block disappears then the problems is in the if, if not then the code itself is the problem, try working out from there, make sure you test one thing at a time, so you could know what is the problematic part

rustyStriker | 2017-10-13 16:27

I tried trying to make a scene of the ball towards the block,
Again, there seems to be a cause in the code.

keito940 | 2017-10-14 05:51

First of all, try using an area2D for the blocks, with the following code:

func _ready():
     connect("body_entered",self,"body_enter")

func body_enter(var body):
     if body.is_in_group("Blocks"):
           queue_free()

second of all, try adding print messages before the if statements(to see the list of colliding bodies) and elsewhere you think it will help

rustyStriker | 2017-10-14 08:38

How do I adapt Area2D to blocks?
Also, how do you display the list of colliding bodies?

keito940 | 2017-10-14 08:53

print(bodies)/ print(str(bodies))
it will make it a string and then display it…

and in order to adapt to are2D you can create a new script and a new scene(tho im not sure area2D works with tilesets)

anyway, try printing the list first

rustyStriker | 2017-10-14 08:59

print(bodies) anyway, try printing the list first

thx.
…But Is there no way to confirm the group to which it belongs?

keito940 | 2017-10-14 10:19

well, try testing without the groups thingy, if the groups is the problem then here it goes, you know where the problem is… btw the groups is capital sensitive which means Blocks != blocks

rustyStriker | 2017-10-14 10:35

I tried it without a group,
There was a cause in the group.
But as for me, I want to make the block disappear if the ball hits the “Blocks” group.
What should I do?

keito940 | 2017-10-14 10:51

Well, you know where the problems is at least… try using a different group name or get a script for the blocks instead which will destroy them if they collide with the ball(you can use the instance name or group but it appears to be problematic

rustyStriker | 2017-10-14 11:23

Because it was useless to change the group name,
I would like to erase it when the ball collides with the script of the block.
How to get a ball collision?

keito940 | 2017-10-15 07:00

first of all, you may have a typo somewhere somehow… and also, if you collide with the ball you can check it by checking the name of the body that is colliding

rustyStriker | 2017-10-15 08:26

if you collide with the ball you can check it by checking the name of the body that is colliding

How check name of the body that is colliding?

Because I am doing machine translation, it can not be helped that English becomes strange.

keito940 | 2017-10-15 08:46

first of all, you may have a typo somewhere somehow…

I do not think it is …

keito940 | 2017-10-16 09:53

okay…
say maybe you can send me the project and i may be able to solve it and send you a solution that works for sure

rustyStriker | 2017-10-16 09:57

Maybe this is it?

http://bit.ly/2x1QQbq

Project’s Currently known problems
(Except what you asked now)
Transparent blocks and paddles are transparent You should be transparent but there is a light green frame
(I asked before but I could not get the point)

keito940 | 2017-10-17 07:04

Ok just what version are you using?

rustyStriker | 2017-10-17 10:00

“Breakout.zip”.

keito940 | 2017-10-18 08:13

of godot… are you using 2.1.4 or the 3. branch?

rustyStriker | 2017-10-18 08:56

Using is 2.1.4.

keito940 | 2017-10-18 10:31

https://goo.gl/R7iSHB

I sorta worked around your problem by adding an area2D to the blocks, and making them a bit bigger than the block itself, while adding a timer mechanic in the script so the block wont disappear before the hit itself…

now no offense man but the organization was kinda hard to read, and a couple of tips, dont put EVERYTHING under a node2D, you can save a rigidbody2d for the player node itself, its actually making it easier to read later on, dont scale collision shapers, as far as i know it suppose to do some problems and try to make the node tree more readable, and use node2D as containers and not kinematicbody2D, hope i helped you out and good luck man

rustyStriker | 2017-10-18 12:16

Thank you very much.
The point is that you have to make it wider than the image, do not you think?
As for the question, is it that the group you designate is not the one to do, but the one who collided?

keito940 | 2017-10-19 08:12

The area2D need to be wider because if not then the ball will wont enter but calculate the position without colliding(godot does that).
The group that i check for is the group i designated for the player itself( aka Player ) so i will know for sure that this is the player and nothing else

rustyStriker | 2017-10-19 08:14

…But Since I moved to Godot 3,
can you tell me how to do it with Godot 3?

keito940 | 2017-11-12 08:36

…What you do is not changed.
Excuse me.

keito940 | 2017-11-15 07:44