0 votes

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://godotengine.org/qa/53519/working-with-tile-set-collision-degree-slopes-and-half-tiles

Godot version 3.2
in Engine by (79 points)

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?

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?

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

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.

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

"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.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.