|Attention||Topic was automatically imported from the old Question2Answer platform.|
Is there any way of create tiles (in a tilemap) to make a slope that is not 45 degrees?
I know that it can be done with CollisionPolygon2D, but it does not sets the same sprite of the others tiles (not that I know).
I saw an old post with the same topic, but with no answear: https://forum.godotengine.org/53519/working-with-tile-set-collision-degree-slopes-and-half-tiles
i honestly do not understand why it should not be possible.
what problems are you encountering while doing it?
“I know that it can be done with CollisionPolygon2D, but it does not sets the same sprite of the others tiles (not that I know).”
what does this mean?
Andrea | 2021-09-27 14:11
I couldn’t find an option to add a texture image in a CollisionPolygon2D. To add a sprite I’m using a Polygon2D over the CollisionPolygon2D (one to render the texture and the other to check for collisions). Is there any way better than this?
Felipe | 2021-09-27 17:51
i think you are making a little confusione here: CollisionPolygon is not intended to show images (therefore it has no option to add texture), it simply create a polygon starting from a list of points in space, and that polygon is used to do things like collision, mouse click detection, etc.
to add a sprite you should use… a sprite
if you are using a Polygon2D to show shapes, maybe you are looking for the “texture” property.
Is there a better way to do it? It depends on your specific needs. When i need a simple “image”, i always go with sprites, they are much easier to use than polygons, and you can use a CollisionPolygon2D with all the shape you need in front of them
Andrea | 2021-09-27 18:11
But if I use a sprite to create a slope A, let’s say w: 100, h: 50, when I create a slope B (w:150, h: 25) I have to use tow sprites, right? Or one of the will be resize and may look odd. I’m trying a way of create a image and apply it to any slope, like the tile map. Don’t kwon if i’m clear… If there is any way of create a image template to use as texturo in any slopes (sizes and degress differents), I don’t know how to do it.
Felipe | 2021-09-27 18:18
You can create a “slope node” and then instance it many time, and after instancing it you can stretch as you like it with the scale property (although I do not suggest it, the collision could not work as well).
But I’m not clear what you mean with “like the tile map”: if you are planning to create a cell for the slope, then no, you need to create one specific cell type for each angle with its own sprite (and if I’m not wrong, using a scaled object to create the tileset can produce errors again)
So, i suggest to keep it easy, at time is better to do a little of repetitive task than overcomplicate everything
Andrea | 2021-09-27 18:52
“if you are planning to create a cell for the slope, then no, you need to create one specific cell type for each angle with its own sprite”
That’s what I was trying to ask. It was something like “click here, drag to there” (a rectangle shape with the mouse, but only half was actualy created (the slope itself, with texture and colision)).
But if I understand you, the best way of doing this is doing one for each angle.
“at time is better to do a little of repetitive task”. I think this resume my ploblem =D
Thanks for all answers, Andrea.
Felipe | 2021-09-27 19:25