# Draw a curved line between two random points?

**URL:** <https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530>\
**Category:** Blueprint\
**Tags:** draw, point, unreal-engine, Blueprint, question\
**Created:** [July 19, 2019, 8:08pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530 "2019-07-19T20:08:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 19, 2019, 8:08pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/1 "2019-07-19T20:08:34Z")

</div>

Hey all! I have a setup that spawns random tiles in a grid. I’m wondering how I would then get two random points on the landscape, draw a randomly curved line. Then do a sphere trace between them deleting any tiles in the way. Then later I’ll spawn different tiles in the now empty spots on the grid.

So basically:

1. Get point “A”.
2. Get point “B”.
3. Draw random, curved line between them.
4. Sphere trace along line.
5. Save HISM’s location data to an array.
6. Delete HISMs.
7. Pull empty spot’s data and populate with new tiles.

Any help appreciated.

---

<div class="post-metadata">

**Author:** ![Mookaroni](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mookaroni](https://forums.unrealengine.com/u/Mookaroni)\
**Post date:** [July 19, 2019, 10:53pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/2 "2019-07-19T22:53:53Z")

</div>

You’d have to use a mathematical function with a randomized variable to get the curved lines. You can then use a collision component on the line and use “Get Overlapping Actors” as an alternative to Sphere trace, then delete the actors that you detect.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 19, 2019, 11:49pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/3 "2019-07-19T23:49:34Z")

</div>

Okay so my world is a grid, I’m getting two random instances of the hisms that spawn and drawing a spline between them.

I can’t seem to get it to remove the plane hisms that it’s overlapping and it seems you can only set the beginning and end points. Hmm…

---

<div class="post-metadata">

**Author:** ![Mookaroni](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mookaroni](https://forums.unrealengine.com/u/Mookaroni)\
**Post date:** [July 20, 2019, 3:17am UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/4 "2019-07-20T03:17:45Z")

</div>

What are you using to delete the plane hisms?

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 20, 2019, 3:22am UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/5 "2019-07-20T03:22:13Z")

</div>

On begin overlap

---

<div class="post-metadata">

**Author:** ![Mookaroni](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mookaroni](https://forums.unrealengine.com/u/Mookaroni)\
**Post date:** [July 20, 2019, 4:44am UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/6 "2019-07-20T04:44:32Z")

</div>

If you’re able to get a volume along the spline, you can use “Get Overlapping Actors” to grab an array of tiles inbetween the two points, then delete each tile in the array.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 20, 2019, 4:47am UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/7 "2019-07-20T04:47:18Z")

</div>

How would I get a volume along the spline?

---

<div class="post-metadata">

**Author:** ![Mookaroni](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mookaroni](https://forums.unrealengine.com/u/Mookaroni)\
**Post date:** [July 20, 2019, 6:45am UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/8 "2019-07-20T06:45:03Z")

</div>

Seems like that’d be difficult. Going back to sphere tracing, you could try something like this that I threw together:

 ![282859-capture1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/6/6e64a323bcaa133b408e4cdc60545550bac88fe8.png)

Though you’d likely have to adjust the number of spline nodes you create and check for duplicates.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 20, 2019, 3:18pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/9 "2019-07-20T15:18:13Z")

</div>

Is there a way to add more points on the spline so it curves? Then sphere trace along that?

Cause won’t a sphere trace go right to the end vs a spline following it’s “path”

* * *

Okay so for some reason when I add points to the spline in construction script it has some extra(I’m assuming it starts with some). So I then clear the spline points and set three points to random tile locations. That seems to work but for some reason the sphere trace doesn’t want to fire? It’s set up exactly like yours.

The actors to be destroyed are HISM Instances so I think that is causing some problems. And for some reason the sphere trace is running multiple times?

 ![282895-splinehelp-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/3/6033e1b4a12a256e1e5833593933fc752ce37129.png)

 ![282896-splinehelp-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/4/c24058f6a5d9bdf163e82e4b394b8be35a381a0c.jpeg)

---

<div class="post-metadata">

**Author:** ![Mookaroni](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mookaroni](https://forums.unrealengine.com/u/Mookaroni)\
**Post date:** [July 20, 2019, 7:12pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/10 "2019-07-20T19:12:29Z")

</div>

The trace is inside the for-loop, so it’ll run for however many spline nodes there are.

You’ll probably want to adjust the “Remove Instance” part at the end, as the array index and instance index probably aren’t interacting the way you think they are.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 20, 2019, 7:55pm UTC](https://forums.unrealengine.com/t/draw-a-curved-line-between-two-random-points/452530/11 "2019-07-20T19:55:16Z")

</div>

Is there a way I can hook the sphere trace up to properly match the spline without running a whole bunch of extra times?
