Race track creation?

How would I go about creating a racetrack?
Making the first outerlayer of the track would complete the polygon shape, and to complete the inner one, would require another polygon shape (imagine a simple track of a big oval and a small oval inside). However completing the polygon shape would not allow me to use the “create points” tool again or else it would delete the current polygon shape.
Would I just make two CollisionPolygon2D’s and duplicate the Polygon2D child into both?

1 Like

Morning Alvin and welcome to the community :wave:

just had a play around this morning and made a test track to see how it would work.

we can have multiple collision shape nodes next to each other (under any node that requires collision shapes), as far as the engines concerned, these are compounded together.

from the quick test that i done, here would be my scene tree
image

when drawing the polygon colliders, i like to think of how i can draw them with a pen, but not take the pen of the paper (if that analogy makes sense)

the inner shape is fine as that would just be a single closed polygon as you said,

when it came to the outer one, if i were to do it with a continual single pen stroke, i would get something like this.
(ive over exaggerated the gap, but these can overlap)

the same would go for the polygon shape that shows the racetrack as the outer polygonn.
only difference i can see would be to get the points as near as possible since this will be visible.
they can overlap as well, since were using a tiled background for it, so you wont see any seams.
(again, ive exaggerated the gap)

putting these 3 together, i ended up with something like this.

when it comes to the actual game, this time we are not looking to see when the player exits our track polygon, but rather enters either of the inner or outer ones.

so the maze in our level, would need to use the body_entered signal instead


and we can add the signal callback to the level script
image

and that plays fine.

hope that helps a bit,
DaZ

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms