This site uses strictly necessary cookies. More Information

X- Home /

# How to get a smooth curved line between two points like those present between the nodes of bolt visual scripting.

I want to make a smooth line from point A to point B similar to what present between the nodes of bolt graph..... I want to use line renderer but the main problem is how to get some points which will make that kind of line possible.....

**Answer** by BastianUrbach
·
May 10 at 02:08 PM

One simple way is to use 4-point Bezier curves. They are pretty easy to calculate:

```
Vector2 Bezier(Vector2 a, Vector2 b, float t) {
return Vector2.Lerp(a, b, t);
}
Vector2 Bezier(Vector2 a, Vector2 b, Vector2 c, float t) {
return Vector2.Lerp(Bezier(a, b, t), Bezier(b, c, t), t);
}
Vector2 Bezier(Vector2 a, Vector2 b, Vector2 c, Vector2 d, float t) {
return Vector2.Lerp(Bezier(a, b, c, t), Bezier(b, c, d, t), t);
}
```

These functions define curves using a number of control points (a, b, c and d). You feed them an interpolation parameter t, which starts at 0 and ends at 1. The one with four control points starts at a and ends at d. The two other points (b and c) control the direction in which the curve leaves a and enters d. It's a bit difficult to explain but try around a bit with some random points and you'll quickly understand how it works.

To use these with a line renderer, generate a number of points, let's say 20, by first evaluating the function at t=0/19 then t=1/19, then t=2/19 and so on up to t=19/19. Set these points as the control points of the line renderer and you should get a nice, smooth curve.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Linear interpolation crash 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Smooth Camera transition (linear interpolation) Error 1 Answer

Move object forward then backwards 1 Answer