Rotate tiles of a Scene Collection

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

Hello. So, I’m using a Tileset to draw my map, but, some of those tiles need to have some behaviour. In this case some spikes that hurt the player.

I have those spikes as a scene, and imported it. It works fine, now, I would like to be able to have those spikes in different rotation, so I don’t have to have 4 different scenes changing only that.

Is it possible? Or, is it possible to add some kind of property to it and control it with a script?


1 Like
:bust_in_silhouette: Reply From: Enfyna

I dont use tilesets but did you try randomizing it in your spike scene ready function. Something like this :

func ready():
    rotation = Vector2(randf_range(0,360),randf_range(0,360))

Sorry this was meant to be a comment. I wasnt aware that I clicked the answer button. :expressionless:

Enfyna | 2023-07-08 18:04

Hey! Thanks but that’s not a possible solution. The reason is that the spikes must be aiming up when they are on the ground, right/left, on a wall etc. I don’t want it random haha.

The solution should be something like with a normal tile, that you can rotate or flip it. I can’t find how to do it on a scene tile

axvemi | 2023-07-08 18:11

I understand would something like this work then :

@export var is_on_wall : bool = true
@export var is_flipped : bool = false
func _ready():
	var random_direction : int = randi_range(0,3)
	var flip = 1 if is_flipped else -1
	if is_on_wall:
		rotation = Vector2(random_direction * 45, flip * 90)
		rotation = Vector2(0, random_direction * 45)

Enfyna | 2023-07-08 18:32

The thing is, can i set those variables from here in any way?

Otherwise, I still need to have 4 different scenes, one with each possible option, and would be the same that just rotating the sprite and not using the script.

axvemi | 2023-07-08 18:48

I looked at the tileset documentation now and I guess this is the feature you want

Using TileSets — Godot Engine (stable) documentation in English

No scripting is needed afterall.

Enfyna | 2023-07-08 19:12

Yes haha, I want exactly that. But, that works for when it’s an atlas. In my case I need it to be an scene since the tile has it’s own script and behaviour. If it’s possible with scenes the option is not showing for me.

axvemi | 2023-07-08 19:15

Actually the documentation talks about that too in here like assigning a damage_per_second variable :

Using TileSets — Godot Engine (stable) documentation in English

Anyways I looked around and tried to search some similar questions but couldnt find anything. I dont use tilesets normally and I cant think of anything else either so I hope you find a solution soon!

Enfyna | 2023-07-08 19:46

Hello, axvemi, i just ran into the same problem. it seems like i am able to rotate tiles that are images but not ones that are scenes. How have you been able to fix / bypass this problem?
thanks in advance

I am also wondering the same thing, for the exact same reason as OP