Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Explosive Pineapple |
hello,
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)
set_cell(bp.x,bp.y,-1)
for the bullet
extends RigidBody2D
var timer = 1
func _process(delta):
if timer >= 0:
timer -= delta
else:
queue_free()
global.bullet_position = position
if theres any better way please let me know.
Explosive Pineapple | 2021-04-18 18:26