ok so what’s happened is that I’m trying to refrence a node from another script to the tile breaker script, and whatever I try and do ends up not working i’ve tried asking for help but nothings coming up, if anyone could help me id really appreictae it.
can you try a print before?
func _ready() -> void:
print(Global.tilemap)
tilePos = Global.tilemap.local_to_map(global_position)
Where are you setting up/assigning Global.tilemap? have you checked if Global.tilemap is null? What do you mean by “not working”? do you get an error?
Wont print, crashes upon starting the scene
tried to assign it in my global class, it basically has nothing in it because i dont know how to refrence the tilemap properly in the global script, and yes its null thats the reason why the error is occuring
Give your tilemap a script and put this in it:
func _ready():
Global.tilemap = self
tried doing that this error occured
When is this tile-breaker scene instanitated?
wdym, do you mean where it is in my file editor or just where it is in general?
when does it enter the scene?
in my tilemap in my other scene i made it a scenes collection with the collision apart of it
Okay yeah thats the problem.
in the tilemap remove the ready-method i gave you and try this:
func _enter_tree():
Global.tilemap = self
you have to put that in the tilemap-script
sorry forgot to clarify i did put in the tilemap script, unless you want me to put it in the tilebreaker script.
you have to write “extends TileMap” at the top of the script
my bad fixed it though same errors occuring though
Hm okay delete this script and try to do this inside of your tilebreaker:
func _ready():
tilePos = get_parent().local_to_map(global_position)
print("tileready!")
okay this is weird. I suggest to do this:
- Remove The ready-method from the tile-breaker and change the _on_area_entered:
func _on_area_entered(area):
if area.is_in_group("EVERHITBOX"):
print("broke")
var tilemap = Global.tilemap
tilemap.erase_cell(0, tilemap.local_to_map(global_position))
...