Rotate TileMap Problem

Godot Version

4.2

Question

I’m working on a 2D platformer with a gimmick, you can turn the level 90 degrees, instantly. so the level turns but the player stays in the same location on the screen.

The problem I’m having is is i can get the tile map to turn without getting an “Invalid get index ‘rotation_degrees’ (on base: ‘TileMap’)” and i also can figure out how to rotate the tilemap on its center.
Any help?

your wordings probably not right, hence it’s confusing to read

this should be:

The problem I’m having is i can’t get the tile map to turn without getting an “Invalid get index ‘rotation_degrees’ (on base: ‘TileMap’)” and i also can’t figure out how to rotate the tilemap on its center.

show how you rotate the TileMap from Code?

Oh dang it :sweat_smile:
Your absolutely right
I can’t believe I messed up like that on my first post :sweat_smile:

I’m on my phone rn but I can get the code soon :grin:

func _process(delta):
(Indent) if Input.is_action_pressed(“turn_left”):
(Indent) (Indent) TileMap.rotation_degrees += 90

yeah it’s not right.
replace the Tilemap with
click drag and drop the tilemap node to the script here so you get the correct nodepath to reference it

or simply if tilemap is the one having this script, just

rotation_degrees+=90

will do

1 Like

oh cool
so just
If Input.is_action_just_pressed(“turn_left”):
indent rotation_degrees += 90

ok, it works
but how do I make it rotate around its center and not the corner?

that will need to set it from parent Node2D of this TileMap
set the Node2D’s position to be exact center as parent of this TileMap, Or move the tilemap to be the center of this Node2D node
then rotate this Node2D node instead of the TileMap

1 Like

Cool, Thank you :grin:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.