[Tutorial] Logical connections/Paths/Colorful Lines only visible in Editor

Hello there ! I’ve been developping some nice things to be able to better visualize logical behavior of our scenes when my team and me are designing some levels. It’s in the context of a 2D puzzle game but you could use these tricks for any kind of projects.

Here, I will show you how I manage to get this result :

https://forums.unrealengine.com/core/image/gif;base64

After this, you will be able to place some actors of your creation and link them with these lines that are only visible in Editor (or in game if you want it to).

Steps :
**1 - **Creating the *Material *and ParticleSystem
**2 - **Scripting a *Macro *setup utility
**3 - **Adding a line through Construction Script of any Actor

Step 1 : Creating the Material and ParticleSystem

Creating the *Material *:
[ul]
[li]In a dedicated folder of your Content Browser, add a new Material and click twice to edit it.[/li][li]In the main properties of the Material, let everything unchanged but Shading Model option that you can set on “Unlit”.[/li][li]In the main graph window, add only one node : *ParticleColor *and link its first pin (the white one) with the Emission Color pin of the Material.[/li][li]Save and wait untill the editor finishes applying the changes. Close the Material.[/li][/ul] Creating the *ParticleSystem *:
[ul]
[li]In the same folder, add a new ParticleSystem and open it in editor.[/li][li]Remove InitialVelocity and ColorOverLife modules, add *BeamData *(in TypeData), *Source *(in Beam), *Target *(in Beam), *InitialColor *(in Color)and ScaleColor/Life (in Color) modules. It should look like this :[/li][/ul]
https://forums.unrealengine.com/core/image/gif;base64

[ul]
[li]Follow the next steps :[/li][LIST]
[li]Under BeamData, set Speed to 0.[/li][li]Under Required, set Material to your new Material.[/li][li]Under LifeTime, set Distribution to a *DistributionFloatConstant *of 0.[/li][li]Under InitialSize, set Distribution to a DistributionVectorConstant of 0.5 - 0.5 - 0.5.[/li][li]Under Source, set SourceMethod to Actor and SourceName to “Source”.[/li][li]Under Target, set TargetMethod to Actor and TargetName to “Target”.[/li][li]Right-click on ScaleColor/Life and chose “Set up particle parameter”.[/li][li]Under ScaleColor/Life, set ParameterName to "LineColor".[/li][/ul]
[li]Save your ParticleSystem and close it.[/li][/LIST] We created a particle system that will simply trace a line between two actors : a source and a target. As parameters, you will be able to chose the starting and ending point along with the line color. We will use a Macro and ParticleSystemComponent in the next steps to automatically spawn our editor line.

Step 2 : Scripting a Macro setup utility

To help us later when adding editor lines, we will make a new Macro library (you can use one of your own if it inherits from Actor class).
[ul]
[li]Create a new Blueprint Macro Library and chose Actor class to inherit from. Open the library in editor.[/li][li]Rename the first Macro “SetupEditorLine”. Add these inputs :[/li][LIST]
[li]“In” - Exec[/li][li]“EditorLine” - *ParticleSystemComponent *(Object Reference)[/li][li]“Source” - Actor (Object Reference)[/li][li]“Target” - *Actor *(Object Reference)[/li][li]“Color” - LinearColor[/li][li]“HiddenInGame” - Boolean[/li][/ul]
[li]Add an Exec output if you want as it will be easier later to script with.[/li][li]Script the macro like shown here :[/li]https://forums.unrealengine.com/core/image/gif;base64

[/LIST] The purpose of this Macro is to setup the different parameters of a ParticleSystemComponent.
Tip : it’s up to you to use a Blueprint Function Library if you prefer it this way.

**Step 3 : Adding a line through Construction Script of any Actor

We now have all we need to add editor lines all over the place ! Let’s explain how we can manage this.

In each blueprint class inherited from Actor you make, there is a Construction Script. It runs at the loading of the level in the game, but also each time something changes on an object placed in the level editor. That is to say, if you change a parameter or move an Actor in thescene from the editor, then editor lines will be updated.

Therefore, we are placing our code in the ConstructionScript of any Actor child class. We need to do two simple things : add a ParticleSystemComponent and call our SetupEditorLine macro to set every parameter. Here is an example :

https://forums.unrealengine.com/filedata/fetch?filedataid=127830&type=thumb

The line will be green, not visible in game and will link the Actor whose script is shown to “OtherActor”, a variable you can expose to make it directly editable from editor (using the pipette tool and clicking on another actor in the scene).

Tip : if you want to, you can directly drag-n-drop a editor line ParticleSystem in your level and setup parameters yourself using the “Expose Parameters” option.

And that’s it ! You can use some of the main principles of this tutorial to make a lot of other things, like printing a special sprite only in Editor, making NPC paths visible for the designers, create options to make them visible or not in debug-game… It’s up to you !

Hope this helped :slight_smile: Bye !