Download

Draw a line between two points - IN-GAME

Hi folks!

Basically I’m trying to grab two positions in the world (one of which is in the BluePrint) and attach a rope to them. The movable piece only goes up/down on Z.

I can draw a line between two World points in BluePrints using the “Draw Debug Line” node. Works great.

I can also draw a two-point spline between two World points using a Spline component and using “Add Spline World Point”. Works great…

^^ Neither of these two options is visible in a release build. As soon as I want my line to be visible and live-updated in-game, I get nowhere. This was real easy in Unity using the line renderer.

The Spline Mesh forces me to set points in Local space (WHY?) and I’ve found no good way to convert World locations to local locations in Unreal. Can’t believe I can’t do something so simple.
Just to reiterate: this is in-game (not through the construction script but updated every Tick).

Anyone got any good tips? Been trying for 4 hours… and kind of embarrassed that I can’t figure this out.

Turning world locations into relative (local) locations is quite simple. If you’ve got point 1 that is a world location and a point 2 that is relative to the first point, but all you have are world locations. You just subtract point 1 from point 2 and the result is the relative location of the the second point to the first point. (see blueprint)

But if you need a rope between two points you could also consider using a cable actor between those two points. The only problem is that it does twitch a bit when it spawns, but you can fix that by increasing solver iterations and/or maybe turning it invisible for a frame or two when it first spawns. You can also set the length if you want and make it short for a stretched tight rope or long for it to sag. Edit: cable components can be attached to objects and you don’t have to manually set the locations per tick yourself.

c8a3765f023da78f0e3addd8d571e98b.png

Or another alternative would be to use a beam particle effect ( https://wiki.unrealengine.com/Beam_Particle_(Tutorial) ) with source and target tangents at 0, and no noise modifier, so it’s just a straight line. Which is really simple to set up, you just have to add the particle system and set the source and target points in world coordinates, kinda like this:

db1d52151514a6c4e635418c4f293137.png

Thanks so much for the help, very kind of you.

I ended up solving it like so:

  • Set both world-points to an empty Spline
  • Add Spline Mesh to the Spline like the image below
  • When looping back around, clear the Spline and start over

8b3f917118a1484d05cebdb782100e7f82fe5ff2.png

However, the points do move a little bit as the line gets longer, so I solved that by giving the mesh a longer attach-point, so it visually doesn’t bother you.
Thanks for the help! Much appreciated.

I was looking for the same type of solution. Thanks!

İ Can’t add points help!