|
|
|
 |
Reply From: |
frannydancis |
The technique I used to accomplish this should be applicable to this situation:
Firstly, you want to make sure that your staticbody2D is actually an Area2D. This is because the Area2D node has the signal, “body_entered,” which we will be using to detect collisions.
After creating an Area2D node, create a collisionshape2D that will serve as the “hitbox” of your wall, for your case it should cover the wall entirely I assume.
Connect the “body_entered” signal from Area2D to the script of your choosing.
func _on_Area2D_body_entered(body):
#Anything you want to happen before the wall is gone above queue_free()
queue_free()
To specify the kinematicbody2D, you can do the following:
func _on_Area2D_body_entered(body):
if body == "Missile":
queue_free()
sorry if my english is so bad, thanks for your answer, but if i change the type of my staticbody2d, lost the property for collide with my player, this like say that the function of be a wall lost and i dont want that lost this function
Player_0 | 2021-04-01 00:26
In that case, here is a step-by-step solution:
- Create an Area2D
- Add a StaticBody2D as a child of Area2D
- Add a CollisionShape2D as a child of the StaticBody2D
- Add a CollisionShape2D as a child of Area2D
Now, it should have the functionality of the wall as well as be destructible using the code above.
frannydancis | 2021-04-01 00:37
exactly, i had not thought of it , thank you for the solution brou
Player_0 | 2021-04-01 00:42
Of course! Good luck and happy developing 
frannydancis | 2021-04-01 00:45