tile maps that can be shot with bullets.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Explosive Pineapple

I am trying to make a top-down shooter game with a character that can shoot bullets. I have 2 types of walls, ones that stop the bullets and I want to make one that can be destroyed with the bullet. for example, when the bullet touches a tile in the tilemap, that tile will disappear. Is this possible using Godot and if so, can you please help me.

i made a way to do it but its very inefficient and doesnt always work. i made a singleton and put a variable for bullet position. then i converted that to tilemap position and deleted any tile that was in that position. the problem is that it only works with the most recent bullet.

for the tilemap

extends TileMap
var bp
func _physics_process(delta):
	bp = world_to_map(global.bullet_position)

for the bullet

extends RigidBody2D
var timer = 1

func _process(delta):
	if timer >= 0:
		timer -= delta
	global.bullet_position = position

if theres any better way please let me know.

Explosive Pineapple | 2021-04-18 18:26

:bust_in_silhouette: Reply From: exuin

Stick an Area2D on the bullet. When the body_entered signal triggers on the TileMap, remove the tile at the position of the area (you’ll probably have to play around with offsets to remove the correct tile). Also remove the bullet as well.

thank you so much. i edited the code i currently had and now it works really good. thanks.

Explosive Pineapple | 2021-04-18 19:20