This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

i want to know how i can generate plateforms of different sizes by using a single tile for runner game through gdscript so that i could randomly spawn them

in Engine by (12 points)

1 Answer

0 votes

If you are using a tilemap, you can set one, two or more cells next to each other to have the same tile ID, which will look like a single platform. For nice borders I suggest 3 tiles, one for the left edge, one for the right edge, and one for tiles in between. Then you can choose how many tiles width the platform has.
For scripting, take a look at TileMap functions:

If you don't use a TileMap then you need to use a 3-slice approach, quite the same way. You would need a texture for left edge, one for right edge, and repeat-draw the middle part to fill the gap in between. The tilemap solution is a bit easier though.

by (29,510 points)

i m trying to to with three slice approach
but using only one texture that "middle texture" .
i dnt know how i could repeat the texture for random nos

It depends how you would it to look like. In general you really need 3 slices (it can be in a single texture though), but you'll need 3 sprites, or 3 draw_rect(), and a rectangular collision shape to match.
Repeating the middle texture depends again how you want it to look like. If you use a separate texture, you can set it to repeat in the resource flags, then when used as a sprite or a draw_rect it will be able to tile along the width (if you provide the appropriate texture region). Otherwise it will stretch.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.