How to create a curve road using with code?

Can someone give me advice on creating a curve road like the image below

Thank you very much.

Hey @hoanguyen,

You could have one plane, with your materials loaded onto it, and clone it, incrementing the rotation of the plane very slightly each time you clone it.

I hope this helps!

1 Like

Thanks for your advice,

However in my case the path curvature will not be fixed, it will change according to the condition. may be slightly curved or very curved,

In addition, there will probably be inclination at these angles.

So connecting the 2 planes will probably not solve the problem.

I’m thinking of using code to draw a mesh, then cover it with a material.

Do you think this is better?

Can’t you change the rotation of the plane in the vertical axis for inclination? Based on your situation, you could do both imo.

@hoanguyen in the 1.27.0 release of PlayCanvas, there is a procedural mesh API that could be used to make the road at runtime.

Alternatively, you could create the road out of small road sections and piece them together.

1 Like

I’d recommend new mesh API as well. Perhaps have a look at this example of how it places quads to where the sphere hits. You could build a road from quads like this.

1 Like