Tilemap grid size change messed up projectile location

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

So I had a functional fireball type mechanic where when you pressed the shoot button a projectile launched from a Position2d node slightly in front of the player, a few tiles I wanted to use weren’t lining up correctly so I changed the cell size from 64x64 to 32x32, but when I went to test my level my projectile now fires way below the Position2d node, I quickly tried changing back to cell size 64x64 but the projectile location is still way off the Position2d node, I tried just moving the Position 2d node waaay up to compensate but without knowing the actual location it’s shooting from it’s really hard to get it to be able to shoot both directions correctly without colliding with the player. I also tried deleting the old position2d and making a new one but it didn’t help. Anyone know how I can fix this? here’s my code, the projectile is called staticball;

const StaticBall = preload(“res://StaticBall.tscn”)

if Input.is_action_just_pressed(“SHOOT”):
shooting = true
anim = “shoot”
$Sprite.play(anim)
$shootime.start()
var staticball = StaticBall.instance()
if sign($Position2D.position.x) == 1:
staticball.set_staticball_direction(1)
else:
staticball.set_staticball_direction(-1)
get_parent().add_child(staticball)
staticball.position = $Position2D.global_position

func _on_shootime_timeout():
shooting = false

:bust_in_silhouette: Reply From: Inces

Find and show the piece of code, that depends on TileMap anywhere. There must be somewhere You are referrencing to TIleMap ( get_node(“TIlemap”), $Tilemap) or some node which is using Tilemaps functions ( for example world_to_map() ).

If You can’t find any, it is eventually issue of TileMaps children retransforming. In this case try to change every “position” property into “global_position” in this code above.

staticball.global_position = $Position2D.globalposition