Unity Tips: Set tile transform via inspector & script (offset, rotation, scale)

preview_player
Показать описание
When working on my Stardew Valley like building tutorial I encountered a problem - I needed to change the properties of my tiles but when I set them in the inspector it did not work when I placed tiles via script. In this short tutorial I am presenting a way to set the tiles offset, rotation and scale via script which works great for the runtime level building. I hope you enjoy it :)

If you would like to show me some support:

If you are looking for a great community:

00:00 The Challenge
00:35 Tile properties in the inspector
01:30 Tile properties in the script
Рекомендации по теме
Комментарии
Автор

Hello Fantastic People! Today very small tip from my side. I thought you may find it useful - it took me a while to figure it out as I wasn't able to find anywhere literally any information about how to achieve that :).

PitiITNet
Автор

Oh thanks, finally I found useful information about this behaviour. Was very surprised when my tiles were behaving properly when you place them in editor, but weren't rotating if I create them programmatically. Very confusing.

Andatrrr
Автор

Tiles are really complicated and i think i have to take a little bit more time to understand this system😂 but great video❤️

sim-card
Автор

This was great, however I am having trouble with the Scale part. I am trying to make some tiles scale in when created (so from 0 to 1) and scale out when destroyed (so scale 1 to 0). I put this in a coroutine and I am lerping the Vector3, no problem there. What happens however is that this TileChangeData class is making *incremental* changes to the tile, not relative like Transform does. So that means it keeps adding/substracting from the scale. Not really letting us say "scale from 0 to 1", it just lets us say "scale by 0.01 this frame" which is terrible.

We could work around this if we could access the current scale of the tile but there is no way to get this either?

Do you have any suggestions?

skabba
Автор

I get "the name Mouse does not exist in the current context"

starkll