Announcement

Collapse
No announcement yet.

Large useful blueprint function library (Morepork Games)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Large useful blueprint function library (Morepork Games)


    (Updated 2017-06-09)

    Hello,

    Been far to uninvolved with the community so far, so wanted to share my fairly large and (imo) useful set of Blueprint functions and macros.

    They come "as is, where is" - by that I mean: I just made functions when I needed them or found myself doing the same thing a lot. So some may be useful, some may be a bit useless, some are lacking fail-safes, and of course there could be bugs (but I'm using most of them in a game I intend to ship within 3 months, so hopefully not).

    I've tried to give them all descriptions though, and also categorized them in the same categories they would be in if they were standard Epic functions (though they are all grouped under "MPG" to keep them clearly separate). I've also tried to make them as performant as possible.

    My personal favourites / ones I use a lot: RandomIntegerByChance, SortFloatArray/SortIntArray, Get Random Element (Array), ForEachLoopReverse, Do N & Notify, Platform Switch, GetDistance, GetFurthestOrClosestLocation, IsObjectOnScreen, GetAllActorsWithTag, V2_Lerp, RoundToMultiple

    I will endeavour to update this post if I have a significant update to the library, but don't expect too much action.

    Hope they are useful to some Please don't distribute modified versions.

    ------------------------------------

    Morepork Blueprint Functions

    Author: Cory Spooner (Morepork Games)
    Twitter: @TheRealSpoonDog
    Website: www.moreporkgames.com
    Last update: 2016-07-05 (UE4.12.4)

    These blueprint functions are free to use in any commercial or non-commercial project, but I'd appreciate a mention if you do!

    The pack contains 185 functions and macros, within 4 files - MoreporkFunctions, MoreporkMacros, MoreporkMacrosActor (some macros had to be in an actor class to use certain nodes), and MoreporkUMGFade (used by a fade macro).

    EDIT: Get latest download 4.22 version here

    Download old/original version here


    Update 2: (44 new nodes)

    Added:
    Branch To Bool - Converts two execution branches to a bool
    ClampColor - Clamps a color (per element)
    ClampRotatorPerElement - Clamps each element of a Vector individually between a minimum and maximum.
    CycleInt - Increments an int if it is still below max, else it will reset it to min
    Delay While - Delays as long as the condition is true. Useful where you're not sure how long to delay because of random startup timing
    FindTagInActors - Returns all actors in the given array that have the given actor tag.
    ForEach Material - Does a loop for each material present on the given primitive. Useful for e.g. creating a dynamic instance of all materials on a mesh.
    ForEachLoop Wait - Same as a regular ForEachLoop, except it will only execute each loop when triggered. Good for when you want to do latent actions in the loop body e.g. stream levels
    ForLoopWait - Same as a regular ForLoop, except it will only execute each loop when triggered. Good for when you want to do latent actions in the loop body e.g. stream levels
    Frame Delay - Delays for a certain number of frames.
    Get Random Element (Copy) - Simple version of Get Random Element for arrays
    Get Random Element (Ref) - Simple version of Get Random Element for arrays
    Get_ALL_WidgetChildren - Gets all the child widgets of the given widget (recursively i.e. including children of children).
    GetAllActorsRenderable - Slightly presumptuous function that gets all actors that have a mesh or particle system component in them. Could be added to.
    GetDistFromScreenCenter - Returns a 0 to 1 value representing the player's distance from the center of the screen (0 is exact center, 1 is edge of screen)
    GetWidgetChildren - Gets all the DIRECT child widgets of the given widget.
    IntToChar - Converts a 0-255 value to it's ASCII character equivalent
    Is Empty - Branches depending on whether the array is empty or not
    LocalVariable_(String) - Just allows storing of a "local" variable in the event graph or in a macro, so you can compute something once and use it several times without fear of it changing.
    LocalVariable_(Transform) - Just allows storing of a "local" variable in the event graph or in a macro, so you can compute something once and use it several times without fear of it changing.
    LocationIsWithinVolume - Returns whether the given location is inside a volume of the given class. NOTE: Will not work if the volume isn't of the "WorldDynamic" object type.
    Max_(Vector) - Returns the maximum value of A and B (the return value is calculated per element, NOT on vector length i.e. Max(A.X,B.X), Max(A.Y,B.Y), Max(A.Z,B.Z) )
    MaxOfByteArray_(Impure) - Returns the maximum value of a byte array, and the value's index
    MaxOrMinOfStringArray - Finds the max or min of a string array (alphabetically) - this is fairly presumptuous and limited, but it's enough to sort a list of strings (e.g. server or player names) in a rudimentary fashion that 99% of people would accept.
    Min_(Vector) - Returns the minimum value of A and B (the return value is calculated per element, NOT on vector length i.e. Min(A.X,B.X), Min(A.Y,B.Y), Min(A.Z,B.Z) )
    More Than X Players - Whether there are more than the given amount of players currently connected.
    NameCompare - Compares two names
    Random Int (No Repeat) - Gives a *brand new* value in the given range each time i.e. no repeats until all values are used or the macro is reset manually
    RandomColorInRange - Returns a random color within the given range. It simply picks a value for each individual element.
    RandomRotatorInRange - Generate a random rotation between min and max
    RandomString - Generates a random string of ASCII characters, of the given length. If ValidChars is empty, then all chars are valid (from 32-127 only).
    RandomVectorInRange - Generate a random vector between min and max (works per component, good for e.g. random scale)
    RemoveAllPlayerWidgets - Removes ALL current user widgets
    Set Level Visibility - Sets the visibility of a streaming level
    SetMaterialQualityLevel - Sets r.MaterialQualityLevel at runtime. 0 = Low, 1 = High, 2 = Medium
    SetScreenResolution - Sets the screen resolution (via console command). If Resolution is empty then it will just set the fullscreen mode.
    SetVsyncEnabled - Sets vsync enabled or not, along with max frames per second (via console command)
    SnapRotatorToDegrees - Snaps a rotator to a certain amount of degrees, on all axis. Only supports whole numbers.
    SortFloatArray - Sorts an array by value. The "Order" output is an array of the original indices in the new order (you can use it to e.g. make another array match the new order of the one you just sorted)
    SortIntArray - Sorts an array by value. The "Order" output is an array of the original indices in the new order (you can use it to e.g. make another array match the new order of the one you just sorted)
    SortStringArray - Sorts a string array alphabetically or reverse-alphabetically. The "Order" output is an array of the original indices in the new order (you can use it to e.g. make another array match the new order of the one you just sorted)
    Stream Level If Valid - Stream levels in and out with automatic validity checking
    StripChars - Strips the given chars from the given string. If "Except" is ticked, then it strips everything BUT the given chars.
    Wait Gate - Will fire the "Condition Met" output once the input has been fired the amount of times specified by "Condition". If "Once Only" is checked, then successive fires are ignored. Unnamed output pin fires regardless.

    Updated: (others were updated too for performance etc but these have added functionality)
    SortFloatArray - Sorts an array by value. The "Order" output is an array of the original indices in the new order (you can use it to e.g. make another array match the new order of the one you just sorted)
    SortIntArray - Sorts an array by value. The "Order" output is an array of the original indices in the new order (you can use it to e.g. make another array match the new order of the one you just sorted)

    Removed:
    AppendAndSetString - Annoyingly appears before the common "Append" node when typing
    GetAllActorsWithTag - There is an official epic one now
    GetLocalPlayerController_(Client) - Unnecessary (GetPlayerController(0) does the same thing
    GetPlayerStateByPlayerIndex - Misleading
    MaxOfFloatArray_(Impure) - Slower than the built-in node
    MaxOfIntArray_(Impure) - Slower than the built-in node
    MinOfFloatArray_(Impure) - Slower than the built-in node
    MinOfIntArray_(Impure) - Slower than the built-in node
    Set Array Element - The official epic one got fixed


    Update 1: (18 new functions and 1 macro)

    GetCurveFloatValue - Same as "Get Float Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveVectorValue - Same as "Get Vector Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveLinearColorValue - Same as "Get Linear Color Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveTimeRange - Same as "Get Time Range", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveValueRange - Same as "Get Value Range", except it allows you to specify the curve asset instead of having to assign it to a variable first.

    RoundFloatDecimals - Rounds a float to the specified number of decimal places e.g. 56.7857 rounded to 2 decimal places would becomes 56.79
    Switch Is Server - The "Server" output is fired if the world that the calling object is from is on the host. Otherwise, the client output is fired.
    ArrayToString_(String) - Converts an array of values to a string so you can easily print the array to the log.
    GetAspectRatio - Gets the current screen aspect ratio (requires small delay after BeginPlay because viewport size has a delay before it is initialized)
    GetScreenScale - Gets the scale of the current screen, relative to a base resolution. Useful for UI scaling (requires small delay after BeginPlay because viewport size has a delay before it is initialized)

    HasScalarParameter - Returns true if the given Material Instance has a parameter with the specified name.
    HasTextureParameter - Returns true if the given Material Instance has a parameter with the specified name.
    HasVectorParameter - Returns true if the given Material Instance has a parameter with the specified name.

    SelectName - If Pick A is True, A is returned, otherwise B is
    SelectParticleSystem - If Pick A is True, A is returned, otherwise B is
    SelectSound - If Pick A is True, A is returned, otherwise B is
    SelectText - If Pick A is True, A is returned, otherwise B is
    SelectVector2D - If Pick A is True, A is returned, otherwise B is

    LocalVariable_(Vector2D) - Just allows storing of a "local" variable in the event graph or in a macro, so you can compute something once and use it several times without fear of it changing.


    Full Descriptions: (Split across two posts due to image count limit - lots of nodes are missing from this list because I couldn't be bothered taking pics of them any more)
    GetBoundsCornerLocations Returns an array of locations representing the corners of a bounding box (use with Get Bounds).
    TraceToGround Convenience function to do a typical ground trace. Will start from Actor if one is supplied, else it will start from the given Location.
    IsActorOverlapping Returns true if the given actor is overlapping any other actors (which you can optionally filter with "Class Filter"), along with the actors it overlapped, if any.
    GetLargestPrimitive Returns the largest component from the given actor. If CollidingOnly is True then it will only compare colliding components. Bounds are used to determine the largest.
    ComponentHasCollisionType Returns true if the given primitive component has the given collision type.
    GetArrayOf_ObjectTypes Returns an array with all of the possible EObjectTypeQuery. Useful if you want to do a trace against all types of things.
    SetCollisionEnabledAll Sets collision enabled type for all primitive components on the given actor.
    IsWithinBounds Returns true if the object or location is within the given bounds. Unticking "completely" means it only has to be partially within the bounds. If Actor is passed in, it will use that, else it will use the component if one is given, else it will check if the given Location is in the bounds. "Actor Use Colliding Only" means it will only use colliding components on the given actor when checking.
    DestroyAllChildComponents Destroys all child components of the given component.
    Component Has Tag Fires output depending on if the given component has the given tag or not.
    GetFloatParameterValue Gets a parameter value from a particle system. ONLY WORKS IF the parameter was initially added as an INSTANCE PARAMETER (can't just get any parameter from a particle system apparently).
    GetVectorParameterValue Gets a parameter value from a particle system. ONLY WORKS IF the parameter was initially added as an INSTANCE PARAMETER (can't just get any parameter from a particle system apparently).
    SpawnActorsFromClass_(Multiple) Same as SpawnActor, except you can specify how many you want to spawn at once.
    GetCameraTransform Gets the transform of the player camera. If PlayerIndex is > -1, it will attempt to get camera for the specified Player Index, else it will get the camera for the local player
    GetPlayerControllerFromPlayerState Gets the player controller associated with the given player state.
    GetPlayerStateByPlayerIndex Gets the player state for a particular player index
    GetLocalPlayerController_(Client) Gets the player controller for the local machine.
    ForEach PlayerState Executes the loop for each player state in the game.
    ForEach PlayerController Executes the loop for each player controller in the game (on the local machine).
    GetCurveFloatValue Same as "Get Float Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveVectorValue Same as "Get Vector Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveLinearColorValue Same as "Get Linear Color Value", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveTimeRange Same as "Get Time Range", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    GetCurveValueRange Same as "Get Value Range", except it allows you to specify the curve asset instead of having to assign it to a variable first.
    Byte Compare Compares two bytes (or enums).
    AddAndSetFloat Convenience function that adds a value to a variable and SETS the variable to the resulting value.
    RoundToMultiple Rounds a float to nearest multiple of int
    FInterp Pulse Interpolate between A and B, applying a sine function (so interpolating between 0 and 1, an Alpha of 0.0 will give 0.0, an Alpha of 0.5 will give 1.0, and an Alpha of 1.0 will give 0.0). Effectively a pulse.
    FInterpStepped Interpolate between A and B in a "stepped" fashion.
    TruncateToMultiple Truncates a float to nearest multiple of int
    MaxOfFloatArray_(Impure) "Impure" version of MaxOfFloatArray, so if you use the value twice in a function it doesn't calculate it every time.
    MinOfFloatArray_(Impure) "Impure" version of MinOfFloatArray, so if you use the value twice in a function it doesn't calculate it every time.
    GetFloatRange Given an array of ranges and a value, returns the range that the value is in e.g. if range<0> is 7 and the value is < 7, it will be in that range.
    TotalOfFloatArray Gives the total value of an array of floats.
    Float Compare Compares two floats (just a cleaner version of "Compare Float").
    RoundFloatDecimals Rounds a float to the specified number of decimal places e.g. 56.7857 rounded to 2 decimal places would becomes 56.79
    ExtendLine Extends a given line and returns the new line endpoint. Line extends by the distance given (in world units), or if LineMultiply is > 0, it will *instead* multiply the current line length.
    AddAndSetInt Convenience function that adds a value to a variable and SETS the variable to the resulting value.
    TotalOfIntArray Gives the total value of an array of integers.
    MaxOfIntArray_(Impure) "Impure" version of MaxOfIntArray, so if you use the value twice in a function it doesn't calculate it every time.
    MinOfIntArray_(Impure) "Impure" version of MinOfIntArray, so if you use the value twice in a function it doesn't calculate it every time.
    GetIntRange Given an array of ranges and a value, returns the range that the value is in e.g. if range<0> is 7 and the value is < 7, it will be in that range.
    Int_/_Int_(ReturnFloat) Returns a float value of A divided by B.
    MapRange_(Int) Returns Value mapped from one range into another. (e.g. 20 normalized from the range 10->50 to 20->40 would result in 25). If "Clamp" is checked, Value is clamped to the input range. If "Truncate" is checked, value is truncated instead of rounding (cheaper).
    Int Compare Compares two integers (just a cleaner version of "Compare Int").
    V2_InterpTo Same as VInterp To except for Vector2
    V2_InterpToConstant Same as VInterp To Constant except for Vector2
    BlendVector Same as the standard Ease function, except it exposes the Exponent and Steps in case the ease type is not constant.
    BlendFloat Same as the standard Ease function, except it exposes the Exponent and Steps in case the ease type is not constant.
    BlendColor Same as the standard Ease function, except it exposes the Exponent and Steps in case the ease type is not constant.
    BlendVector2D Same as the standard Ease function, except it exposes the Exponent and Steps in case the ease type is not constant.
    RandomIntegerByChance Generates a random integer, biased by the input Chances array e.g. if Chances<1> is 1 and Chances<2> is 10, then the output is 10x more likely to be 2. If seed is left at -1, it uses a random seed each time. Returns -1 if invalid chances passed in.
    RandomFloatInRange_(Impure) "Impure" version of RandomFloatInRange, so if you use the value twice in a function it doesn't calculate it every time.
    RandomBoolByChance Gives a random bool based on the chance specified e.g. if True_Chances is 1 and False_Chances is 10, the result is 10x more likely to be false.
    FindLookAtRotation_(YawOnly) Same as "Find Look at Rotation" except ignores the Z position of the start/target. Essentially this is a "Find 2D Look at Rotation" (top-down).
    VectorIsNull Returns true if the vector is exactly 0,0,0. Like "Equal (Vector)" except without a tolerance, must be exactly 0.0.
    VectorIsNegative Returns true if the TOTAL OF THE COMPONENTS of a vector is less than zero (not the length of the vector)
    Absolute_(Vector) Returns the absolute (positive) value of A
    AddAndSetVector Convenience function that adds a value to a variable and SETS the variable to the resulting value.
    GetMaxElementIndex Returns the index of the AXIS with the highest value
    ClampVectorPerElement Clamps each element of a Vector individually between a minimum and maximum.
    Vector Compare Compares the length/magnitude of two vectors.
    Direction Compare Compares two directions, with a tolerance value (1.0 is exactly the same direction, -1.0 is exactly the opposite direction, 0.0 is perpedicular). Also outputs what the result was.
    Equal_(Vector2D) Returns true if A is equal to B
    vector2d_*_vector2d Returns A multiplied by B
    vector2d_/_vector2d Returns A divided by B
    V2_Lerp Same as Lerp (Vector) except for Vector 2D.
    Absolute_(Vector2D) Returns the absolute (positive) value of A
    ClampVector2D_Size Clamps a Vector 2D between a minimum and maximum LENGTH.
    ClampVector2D_PerElement Clamps each element of a Vector 2D individually between a minimum and maximum.
    Vector2D Compare Compares the length/magnitude of two vector 2Ds.
    SelectVector2D If Pick A is True, A is returned, otherwise B is
    Switch Is Server The "Server" output is fired if the world that the calling object is from is on the host. Otherwise, the client output is fired.
    SetSimulatePhysicsAll Sets "simulate physics" for all primitive components on the given actor.
    SetActorPhysicsEnabled Sets all "physics" (collision AND physics simulation) on or off for all primitives on the given actor (and sets collision on the actor itself, too). If input is false, CollisionTypeIfEnabling is ignored and collision is turned off. If you ONLY want to set physics simulation and leave collision as it is (or vice versa), use SetCollisionEnabledAll or SetSimulatePhysicsAll.
    GetPhysicsTotalMovementAmount Gets the magnitude of the component's linear AND angular velocity. Useful in situations when you're checking for any movement before doing something.
    GetDynamicMaterial Gets the MaterialInstanceDynamic assigned to the given component, if it has one
    HasScalarParameter Returns true if the given Material Instance has a parameter with the specified name.
    HasTextureParameter Returns true if the given Material Instance has a parameter with the specified name.
    HasVectorParameter Returns true if the given Material Instance has a parameter with the specified name.
    CreateAndAddWidget Creates a widget of the specified class and adds it to the viewport.
    Toggle Widget Toggles a widget's enabled status AND it's visibility
    Last edited by Spoondog; 04-05-2019, 08:03 PM.

  • replied
    Anyone please maybe have "ready-to-use" version for 4.21? Thank You.

    Leave a comment:


  • replied
    Hi,I import older version into 4.21,it cannot compile.Could you provide a 4.21 version for me ?Thanks a lot.

    Leave a comment:


  • replied
    Fantastic work!

    Leave a comment:


  • replied
    Spoondog , Thank You

    Leave a comment:


  • replied
    I got a few minutes to add missing descriptions and sort the new functions into categories, so I updated the file - same link

    Leave a comment:


  • replied
    Originally posted by Spoondog View Post
    “Stop” should be connected to “Stop” . “Then 0” should be connected to “Start”
    Great! thank you!

    Leave a comment:


  • replied
    “Stop” should be connected to “Stop” . “Then 0” should be connected to “Start”

    Leave a comment:


  • replied
    Originally posted by Spoondog View Post
    It is the "Alpha Over Time" macro. Whenever I upgrade I always open the morepork UMG fade first, compile/save, then object macros, save, then actor macros, save, then morepork functions, compile/save.

    Anyway, since I don't have time to maintain these properly I thought I would upload my most recent version, which is compiled & saved with 4.22.

    Download Morepork Functions 4.22 here: https://drive.google.com/file/d/1jMZ...ew?usp=sharing

    Please note that I haven't had time to organize it properly so some functions/macros are uncategorized and probably lack descriptions (might even be a couple that don't work, I can't remember).

    New functions & macros, uncategorized:

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	13.2 KB
ID:	1603931Click image for larger version

Name:	Capture2.PNG
Views:	1
Size:	6.1 KB
ID:	1603932

    In future I hope to do a big cleanup and combine these into a new toolset with my editor utility scripts.
    This is the right place of wire?

    Leave a comment:


  • replied
    Originally posted by Tarabakti View Post
    wat is macro i lost?
    It is the "Alpha Over Time" macro. Whenever I upgrade I always open the morepork UMG fade first, compile/save, then object macros, save, then actor macros, save, then morepork functions, compile/save.

    Anyway, since I don't have time to maintain these properly I thought I would upload my most recent version, which is compiled & saved with 4.22.

    Download Morepork Functions 4.22 here: https://drive.google.com/file/d/1jMZ...ew?usp=sharing

    New functions & macros:

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	13.2 KB ID:	1603931Click image for larger version  Name:	Capture2.PNG Views:	1 Size:	6.1 KB ID:	1603932

    In future I hope to do a big cleanup and combine these into a new toolset with my editor utility scripts.
    Last edited by Spoondog; 04-14-2019, 06:26 PM.

    Leave a comment:


  • replied
    I have this macro error, wat is macro i lost? and why unreal crash when i try to open Morepork UMG Fade?

    Leave a comment:


  • replied
    Thanks a lot. I just got it and used the sorting string array function successfully within a few minutes.

    Leave a comment:


  • replied
    Thanks for these, super useful. Got a question though about the string sort. It orders things a little weird like "Apple Pie, Apple, App, Baseball, Cat, Dog, Etc" I'm guessing because of the string length? Is there any way for it to sort them App, Apple, Apple Pie, Baseball, Cat, Dog, Etc? Thanks!

    Leave a comment:


  • replied
    This is brilliant. My eyes got crossed trying to read them all hahaha. Is there split screen function?

    Leave a comment:


  • replied
    When i try to open MorePorkUMGfade the editor crashes i also get a bunch of load errors, using 4.21

    Leave a comment:

Working...
X