This beginner-level Unreal Engine 4 tutorial will show you how to make a simple Distance Measurement Tool using Blueprint. It\u2019s my hope it\u2019ll also serve as a good general introduction to making your own editor tools as well. Little gadgets like these can really speed up your workflow, and make life a whole lot easier for you and your team.\n\n\n\nMy focus today will be on creating a simple actor that can measure the distance between user-defined points in space. As I\u2019ve found many of the alternative tools on the Marketplace to be over-designed and\/or clunky, I want my tool to be practical and uncomplicated.\n\n\n\nFor those who\u2019re already familiar with Blueprint and just want to see how it works, you can download the project here.\n\n\n\nHow it works\n\n\n\nThe Distance Measurement Tool is spline-based. It includes a few Blueprint functions that let you adjust the spline to get the distance between two or more points in space.\n\n\n\n\n\n\n\nTo use it, drag-and-drop it into your scene. You can change the end point by moving it around like you would any other spline component. The length value will automatically update. You can add additional points by holding the alt-key and dragging outwards.\n\n\n\nUser variables\n\n\n\nThere are a few ease-of-use functions which can be found in the details panel under \u2018Config\u2019.\n\n\n\n\n\n\n\nReset Tangents: Resets all spline tangents back to their default values.\n\n\n\nZero-Out Tangents: Sets all spline tangents to zero. This is useful to quickly remove all spline curvature.\n\n\n\nUnit Type: This setting gives you the option to change the unit of measurement the tool uses. By default it\u2019s set to centimeters.\n\n\n\nAnchor Actor: If this value isn\u2019t null, the end of the spline will lock to the actor specified here.\n\n\n\nThat\u2019s it. Pretty simple, and it will work both in the editor and at runtime.\n\n\n\nLet\u2019s get started!\n\n\n\nProject setup\n\n\n\nWe\u2019re going to start by making a new Unreal Engine project. For this tutorial I\u2019m using version 4.26, but it should work for earlier\/later versions as well.\n\n\n\n\n\n\n\nI\u2019m going to create an empty Blueprint-only project this time - you won\u2019t need any C++ for this. I\u2019m going to also add the Starter Content purely so I have some props to test with that are more interesting that a couple of cubes.\n\n\n\n\n\n\n\nOnce we\u2019re up and running, the first thing I\u2019m going to do is make a new folder in the root of my Content Browser called MeasuringTool. I\u2019m going to make sure all of the assets I create for the tool stay within this folder. This is really important as I plan to migrate these files to several of my projects going forward, and I don\u2019t want these files to get mixed-in or conflict with already existing assets.\n\n\n\nUnit types\n\n\n\nThe first thing we\u2019re going to make inside the MeasuringTool folder is an enumeration (or enum) called EUnitTypes. This is how you\u2019ll be able to set what unit of measurement you\u2019d like to use.\n\n\n\nMy enum settings look like this.\n\n\n\nText Material\n\n\n\nBefore we start our Blueprint we need to make a new material for its text readout component. This material will be a close copy of the text render material Unreal uses by default, but we\u2019ll be modifying it to always face the camera. This step could be done at any time (or even skipped, really) but it\u2019s best to get it out of the way now.\n\n\n\nWe could create this material from scratch, but since the focus of this tutorial isn\u2019t material creation let\u2019s take a shortcut. In your Content Browser\u2019s view options there is a checkbox marked \u2018Show Engine Content\u2019. With that enabled, run a search for DefaultTextMaterialOpaque.\n\n\n\n\n\n\n\nWe don\u2019t want to modify this material (directly altering engine content is nearly always a terrible idea), so right click and make a duplicate. Name it something sensible (I called mine M_TextMaterial_CameraFacing), and drag it into your MeasuringTool folder. We\u2019re going to make two quick changes to this material.\n\n\n\n\n\n\n\nFirstly, plug Vertex Color output into Emissive Color so the text will be visible even in low-light conditions.\n\n\n\nThe second change will be to create an 'AlignMeshToTheCamera' function and two vector3 values. This function will alter the vertices of the mesh its applied to so it it always faces the camera. The default settings makes it present the mesh at the wrong angle, so we need to tweak it a little.\n\n\n\nPlug your vectors into Custom Object Basis 2 & 3 (1 can stay default), and set them to (1,0,0) and (0,-1,0) respectively. What this does is switch the (now inverted) Y and Z axes to change the aligned rotation so we can read the text properly.\n\n\n\nYou can close the material now, we won't need to come back.\n\n\n\nCreating the Blueprint, adding components\n\n\n\nOnce you\u2019ve got your enum and your text material, we\u2019re going to create a new Blueprint class. We\u2019re going to select \u2018Actor\u2019 as its parent class because we want it to be a simple object with a transform that we can drag and drop into the scene. I named mine BP_MeasuringTool.\n\n\n\n\n\n\n\nOpen up your new Blueprint and add the following components:\n\n\n\nSplineThe length of the spline component is what the tool will measure. We will be making a few functions that will define where it starts and ends.Text Render (x2)We need text render components to output the distance value of our spline in a legible format. Name one of these Value, and the other Distance.BillboardThe billboard isn\u2019t strictly necessary. It\u2019s just for show. That said, it helps pick out the Measuring Tool from the background, and makes the whole thing look a little more professional.\n\n\n\nWhen you\u2019ve added the components, click and drag the billboard to the top of the hierarchy to make it the parent component of your actor, and likewise parent your Distance text render to Value. Your Blueprint layout should look like this.\n\n\n\n\n\n\n\nComponent settings\n\n\n\nBillboard\n\n\n\nYou can set your billboard sprite to anything you like. It\u2019s purely an aid to identify the Measurement Tool even if it\u2019s partially obscured. If you\u2019re feeling particularly artistic you can even create your own!\n\n\n\n\n\n\n\nI found that the sprite texture 'T_Loft_Spline' was a good fit for me. It's an engine texture so to see if you\u2019ll have to keep \u2018Show Engine Content\u2019 enabled. Don\u2019t worry about this file sitting outside your content folder, since it\u2019s an unchanged engine asset, Unreal will know where to find it.\n\n\n\nSpline\n\n\n\nThe only setting you\u2019ll need to change here is to check the box for \u2018Input Spline Points to Construction Script\u2019. This is important because exposes the spline point data to the construction script. Without that, our tool won\u2019t update correctly in the editor.\n\n\n\n\n\n\n\nText Renders\n\n\n\nBoth of your text render components should have our new M_TextMaterial_CameraFacing material assigned, and both horizontal and vertical alignment set to center.\n\n\n\nSet the Distance text value to \u2018DISTANCE\u2019, set its World Size to 16, and add 22cm in the Z axis so it sits above its parent. This is all we\u2019ll do with this component, as it\u2019s just for legibility.\n\n\n\n\n\n\n\nThe Value text render\u2019s position and text value will be set programmatically so it can stay where it is, but set its World Size value to 26.\n\n\n\n\n\n\n\nUpdating the distance value\n\n\n\nJump back into your Blueprint graph and create a new EUnitTypes variable. Name it UnitType. This will be one of the variables that you\u2019ll use outside the Blueprint editor, so click the eye icon to make it public and put it in an easily identifiable category - I like to use Config for these.\n\n\n\n\n\n\n\nNext, create a new function called UpdateText. This will set the position and value of our Value render text component based on the length of the spline.\n\n\n\n\n\n\n\nClick the image to see the function in a higher resolution.\n\n\n\nFire this function from both your Construction Script and your Event Tick so it works inside the editor and at runtime.\n\n\n\n\n\n\n\nIf you drag and drop BP_MeasurementTool into your scene now, you\u2019ll be able to move your spline around and create new points, and the text will automatically update its value based on the unit type you have set in the Blueprint\u2019s Details panel.\n\n\n\nTangent control\n\n\n\nSplines can be fiddly. The next thing we\u2019re going to add is some functionality that will let us set all of our tangents with a single click. To do this we\u2019ll need three new functions inside our Blueprint.\n\n\n\nThe first is \u2018SetTangents\u2019, which will simply loop through all of our spline\u2019s tangents and set them to a specified vector input.\n\n\n\n\n\n\n\nThe last two are very similar, I've called them ZeroOutTangents and ResetTangents respectively. Each one will fire SetTangents with a different input - the former setting all tangents to 0,0,0 (no curvature) and the latter to the spline\u2019s default value of 0,0,100.\n\n\n\n\n\n\n\nThese are the functions we\u2019ll fire in the editor, so assign them to your Config category and make sure both of their \u2018Call in Editor\u2019 checkboxes are ticked. This turns them into buttons in your Blueprints details panel.\n\n\n\n\n\n\n\nSnapping to Actor\n\n\n\nThe last bit of functionality we\u2019re going to add to our Measurement Tool is the capability to snap the end of our spline to an actor\u2019s location. To do this we\u2019ll need one last variable in our Config section, a reference to an actor. I called mine AnchorActor. This is another one we\u2019ll tweak per-instance, so remember to set it to publicly editable.\n\n\n\nCreate a new function called SnapToActor, and add it to both your Construction Script and Event Tick. Make sure it fires before your text update function or the readout will be out of date!\n\n\n\n\n\n\n\nThe SnapToActor function is simple. It looks to see if you\u2019ve assigned an actor, and if so it will move the last spline point to its location. If your AnchorActor variable is empty, it does nothing. Easy!\n\n\n\n\n\n\n\nWrap up\n\n\n\nWhile not having all the features of the ones you might find on the Unreal Marketplace, I hope this simple measuring tool helps you with your projects and that you find it a bit less clunky to work with.\n\n\n\nClick here to download an asset pack which includes all the content within my MeasuringTool folder. Thanks for reading, and good luck with your projects.