Can I get the scale and rotation value from TileMaps?

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

I use the TileMap to spawn in my scene like enemy coins etc. I can rotate and flip the sprite in the TileMap but i dont know how to get the rotation and scale values of those tiles. How can I get those values, is there a way to get them?

:bust_in_silhouette: Reply From: Sween123

To get if the target tile is flipped, use is_cell_x_flipped() or is_cell_y_flipped()
You can’t get the rotation degree if your objects are directly from the TileMap.
The scale value can be only set for the whole TileMap, to get it, use get_scale()
You can try to use the tiles in the TileMap to represent different objects, and you start iterating all the tiles at the beginning of the game. For each tile, you instance a scene you created youself for the object and add it into the game world. This way it will be much more convenient for control and get whatever info you have for the object, including rotation_degrees and scale value.

:bust_in_silhouette: Reply From: Gavin

You can use is_cell_x_flipped(), is_cell_y_flipped(), and is_cell_transposed() to check the orientation of the cell. There are 8 orientations, which can be represented as an angle (0,90,180, or 270 degrees) and a flip, either axis would be fine to flip along, but I’m using y for the code here:

#returns array of [angle,yflip]
static func getRotation(xflip, yflip, transpose)->Array:
	if (!xflip and !transpose):
		return [0.0, yflip]
	elif(xflip  and !transpose ):
		[PI, !yflip]
	elif(!xflip and transpose):
		return [-PI/2, !yflip]
	elif(xflip and transpose):
		return [PI/2, yflip]	

That is a starting point, if you care whether the node is flipped on the x axis you could switch all the xflip and yflips. If your cell is symmetrical and you only care about rotation, then you want to add PI to each angle if yflip is true.