(39) 's Extra Blueprint Nodes for You as a Plugin, No C++ Required!

~~

**2 Two Nodes For You

Create UObject

Create Primitive Component, Added to Scene at Location!**

These two nodes let you create UObjects at runtime!

I recently needed to create UObjects in Blueprints for a special inventory system! Please note you can use my node to create UObjects that you make Blueprintable via C++ !

Please note you absolutely must save off the return value to a variable or UE4 will Garbage Collect your new UObject within a short!

Please especially note that if you create a Primitive Component, I actually add it to the world for you so it is visible and has collision!


**C++ Code For You**

Here's the code!



```


UObject* UVictoryBPFunctionLibrary::**CreateObject**(UObject* WorldContextObject,UClass* TheObjectClass, FName Name)
{
	if(!TheObjectClass) return NULL;
	//~~~~~~~~~~~~~~~~~
	
	//using a context  to get the world!
    UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject);
	if(!World) return NULL;
	//~~~~~~~~~~~
	 
	return StaticConstructObject( TheObjectClass, World, Name);
}


```





```


UPrimitiveComponent* UVictoryBPFunctionLibrary::**CreatePrimitiveComponent**(
	UObject* WorldContextObject, 
	TSubclassOf<UPrimitiveComponent> CompClass, 
	FName Name,
	FVector Location, 
	FRotator Rotation
){
	if(!CompClass) return NULL;
	//~~~~~~~~~~~~~~~~~
	
	//using a context  to get the world!
    UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject);
	if(!World) return NULL;
	//~~~~~~~~~~~
	 
	UPrimitiveComponent* NewComp = ConstructObject<UPrimitiveComponent>( CompClass, World, Name);
	if(!NewComp) return NULL;
	//~~~~~~~~~~~~~
	 
	NewComp->SetWorldLocation(Location);
	NewComp->SetWorldRotation(Rotation);
	NewComp->RegisterComponentWithWorld(World);
	
	return NewComp;
}


```



♥

any one getting a error of missing Dll files?

Until 4.8 or so you need to include even just an empty C++ class, to get the plugin to compile in a packaged game.

If you are having missing dll errors in editor build, make sure you are using 4.6.1 with my plugin. I will release 4.7 version when 4.7 is released. The current 4.7 in the launcher is for testing only, not commercial development.

:slight_smile:

**New Nodes

Combine Multiple Strings & Append Multiple Strings**

With these latest nodes you can combine as many strings as you want!

Note the “Add Pin” option!

Combine Strings Multi = I put a space between each string for you!

Append Multiple = Strings are combined without any additional formatting.


**Special Thanks**

Special thanks to Key To Truth for contributing the Append Multiple node!

I was inspired by Key To Truth's offering to make Combine Strings Multi :)

Download Link (6.5mb)

UE4 Wiki, Plugin Download Page

Enjoy!

:heart:

**Two New AI Nodes

Get Closest Actor Of Class In Radius of Location

Get Closest Actor of Class In Radius of Actor**

These nodes are great for use with AI calculations!


**C++ Code For You**

Here's my c++ code for **Get Closest Actor of Class In Radius of Actor**!



```


AActor* UVictoryBPFunctionLibrary::GetClosestActorOfClassInRadiusOfActor(
	UObject* WorldContextObject, 
	TSubclassOf<AActor> ActorClass, 
	AActor* ActorCenter, 
	float Radius, 
	bool& IsValid
){ 
	IsValid = false;
	  
	if(!ActorCenter)
	{
		return nullptr;
	}
	
	const FVector Center = ActorCenter->GetActorLocation();
	
	//using a context  to get the world!
    UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject);
	if(!World) return nullptr;
	//~~~~~~~~~~~
	
	AActor* ClosestActor 		= nullptr;
	float MinDistanceSq 		= Radius*Radius;	// Radius
	
	for (TActorIterator<AActor> Itr(World, ActorClass); Itr; ++Itr)
	{
		//Skip ActorCenter!
		if(*Itr == ActorCenter) continue;
		//~~~~~~~~~~~~~~~~~
		
		const float DistanceSquared = FVector::DistSquared(Center, Itr->GetActorLocation());

		//Is  the closest possible actor within the  radius?
		if (DistanceSquared < MinDistanceSq)
		{
			ClosestActor = *Itr;					//New Output!
			MinDistanceSq = DistanceSquared;		//New Min!
		}
	}

   IsValid = true;
   return ClosestActor;
}


```



Download Link (6.5mb)

UE4 Wiki, Plugin Download Page

Enjoy!

:heart:

**Using these nodes in my plugin you can now easily make your own translation animations for 2D games and UMG!
**
I realized the need for these animations while trying to manually animate UMG widgets in BP.

I am in process of submitting as a pull request for the main engine.

UE4 Wiki, Plugin Download Page

Enjoy!

Get OS Platform

Now you can perform different actions based on which OS is currently being used!

Platforms you can check for:

**Windows
Mac
Linux

PS4
XBoxOne

iOS
Android

HTML5

WIN RT
WIN RT ARM**

Enjoy!

I have a problem with the “Get static mesh vertex locations” node.

It doesn’t work it a packed game.

Blueprint:

Editor:

Packed:

I’ve also tried to use node from the game code and not as a plugin and it gave me the save results.

The level builder system i’m making is really depended on node, please help :expressionless:

@

“It doesn’t work it a packed game.”

I have had the same experience and reported to epic a while back :slight_smile:

I’ve experienced with getting vertex locations in packaged games since 4.3

If you start a new Answerhub, link me and I can add more info to your report :slight_smile:

Please include your pictures and then I can add info, you could also add my code below to the initial post.


For Epic Staff:

Here's the code being used that works perfect in pre-packaged game and does not work in packaged game.

**It seems that using the Render Data / LOD info in packaged game** does not work some reason?



```


Comp->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer


```



Is there an after-packaging better way to get the vertex position info?

Please note the rotation/translation of each vertex is scaled by the FTransform to match actor scaling and rotation.



```


Comp->GetComponentLocation() + RV_Transform.TransformVector(VertexBuffer->VertexPosition(Itr))


```



Entire C++ Code



bool UVictoryBPFunctionLibrary::GetStaticMeshVertexLocations(UStaticMeshComponent* Comp, TArray<FVector>& VertexPositions)
{
	if(!Comp) return false;
	if(!Comp->IsValidLowLevel()) return false;
	
	//~~~~~~~~~~~~~~~~~~~~
	//				Vertex Buffer
	if(! Comp) 									return false;
	if(! Comp->StaticMesh) 					return false;
	if(! Comp->StaticMesh->RenderData) 	return false;
	if( Comp->StaticMesh->RenderData->LODResources.Num() < 1) return false;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	//~~~ End of Pointer Safety Checks ~~~
	
	//~~~~~~~~~~~~
	VertexPositions.Empty();
	//~~~~~~~~~~~~
	
	FPositionVertexBuffer* VertexBuffer = NULL;
	VertexBuffer = & Comp->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer;
	if(!VertexBuffer) return false;
	//~~~~~~~~~~~~~~~~
	
	int32 VertexCount = VertexBuffer->GetNumVertices();
	 
	FTransform RV_Transform = Comp->GetComponentTransform(); 
	for(int32 Itr = 0; Itr < VertexCount; Itr++)
	{
		VertexPositions.Add(
			Comp->GetComponentLocation() + RV_Transform.TransformVector(VertexBuffer->VertexPosition(Itr))
		);
	}
	
	return true;
}



is the link to the AnswerHub page:

Thanks for the help , it was really frustrating to debug thing, i really need it to work, i hope they fix it soon or at least find a workaround.

It seems like is a known :

And wiki page has a link to tutorial ( Integrating PhysX Code into Your Project )
Maybe can make some super node for us out of information ? :slight_smile:

Wow that’s an awesome wiki by Vebski,** thank you Vebski!**

I will try turning that into a BP node shortly.

I also posted in your answerhub !

:slight_smile:

**Improved Get Vertex Locations of Static Mesh

Now works in Packaged Games**

I have re-written my Get Vertex Positions BP node so that it works in packaged games!

Special thanks to Vebski for pointing out that using a PhysX method does work in packaged games!


**My C++ Code For You**

See my PhysX wiki for the basic build.cs setup:
https://wiki.unrealengine.com/PhysX,_Integrating_PhysX_Code_into_Your_Project

Here is the code I wrote to get  of the transformed vertex positions using the Body Instance and PhysX code!

I am doing many safety checks to ensure the Body Instance data is valid before utilizing it, and the result is that now you can get accurate vertex locations in packaged games!



```


//~~~ PhysX ~~~
#include "PhysXIncludes.h"
#include "PhysicsPublic.h"		//For the ptou conversions
//~~~~~~~~~~~

//Get Transformed Vertex positions of any static mesh! -
bool UVictoryBPFunctionLibrary::GetStaticMeshVertexLocations(UStaticMeshComponent* Comp, TArray<FVector>& VertexPositions)
{
	
	if(!Comp || !Comp->IsValidLowLevel()) 
	{
		return false;
	}
	//~~~~~~~~~~~~~~~~~~~~~~~
	
	//Component Transform
	FTransform RV_Transform = Comp->GetComponentTransform(); 
	
	//Body Setup valid?
	UBodySetup* BodySetup = Comp->GetBodySetup();
	
	if(!BodySetup || !BodySetup->IsValidLowLevel())
	{
		return false;
	}  
	
	//Get the Px Mesh!
	PxTriangleMesh* TriMesh = BodySetup->TriMesh;
	 
	if(!TriMesh) 
	{
		return false;
	}
	//~~~~~~~~~~~~~~~~
	
	//Number of vertices
	PxU32 VertexCount 			= TriMesh->getNbVertices();
	
	//Vertex array
	const PxVec3* Vertices 	= TriMesh->getVertices();
	
	//For each vertex, transform the position to match the component Transform 
	for(PxU32 v = 0; v < VertexCount; v++)
	{ 
		VertexPositions.Add(RV_Transform.TransformPosition(P2UVector(Vertices[v])));
	}
	
	return true;
} 


```





**UE4 Wiki, Plugin Download Page**
https://wiki.unrealengine.com/File:VictoryPlugin.zip

Enjoy!

:)

is awesome ! Funny how you used a tutorial that used yours, you guys are helping each other XD

Hello !

I have issues compiling for Android, I didnt try compiling for iOS yet!
I use Unreal Engine 4.6.1, your plugin is from today from the wikipage!

I have excactly .

Well I’m definitely using 4.6.1 for the plugin builds, if nothing else we can wait till 4.7 official release which should be quite soon, and try again then.

The person who posted the above post found to be the reason for their error:

“Edit - I figured out the problem - stupid me used a wrong version of the plugin when I pasted it into my temp project directory. If you see problem with others, I’m pretty sure that’s what the problem was. Thanks for the great plugin.”

Hee hee yea!

Sharing makes us stronger!

:heart:

A couple of BP node questions and suggestions here with some background.

Background
Originally, I wanted to use an array of structs to manage data records. Each record could then have its own array of tags (defined in a BP enum). I could then add, remove, and check for tags whenever I want to affect gameplay and visuals.

However, there is a massive, completely ridiculous problem constantly plaguing of my projects: arrays of structs are currently busted in BP as you can’t set the member variables of individual structs in the array. Technically, you can replace the original struct in the array with a newly-built struct. However, that’s only true when the array is the original. In my case, I’m using a function to search through my records and return a separate search results array. If I were to use the old make-and-replace hack, it would only affect the search results array; the original data would never be touched.

Therefore, in my current project, I’m saving data to an array of strings. Each of those strings is a list of tags separated by commas. Mockup:


{"road,built", "bridge", "bridge,built", "road", ""}

gives me the freedom to add, remove, and check for as many arbitrary tags that I want. However, adding additional data complicates things. With existing string manipulation, something like is possible but unwieldy:


{"position:north|tags:road,built", "position:east|tags:bridge,broken"}

I’d love to use TMaps or Objects, but neither of them can be replicated.

Questions
Can TMaps components be made replicable?

Currently, TMaps crash the editor when their key/value pair isn’t found. Learned that when testing whether or not they replicated. Turns out, they don’t :stuck_out_tongue: Is it possible to implement some error handling and a PairFound boolean?

Suggestions
A string array to string (collapse/flatten) node (with deliminator string) would be nice.

Regular expressions are probably a can of worms you don’t want to open, but they would be quite useful.

, another can of worms, could replace the monstrosity that is Structs, assuming the output could be saved to a string for easy replication. Edit: found an existing plugin. I’ll test it out once it’s updated to 4.6.1.

An in-memory (fileless) ini stored in a single string (so that it could be added to an array) could also fill the role quite nicely without becoming overcomplicated.

Finally, thanks for the work you’ve put into these nodes. They’re quite useful.

No it wasnt a wrong version, you simply dont ship the binaries (dll) for Android, or iOS, or linux or mac :stuck_out_tongue_winking_eye:
So i had to rebuild the solution, and compile to the targets (android, ios, etc.) in shipping mode.
Now it works.
Thanks.

Btw : why dont you include stuff like a node for remove playercontroller, or spawning actors from construction script? I can give you my bp library if you want.

Greetings

I have reproduced and fixed crash! See below!


**Victory BP TMap Component Update!**

Each of the Get Nodes will now also return a bool to let you know if a **valid pair** was found!

If you were getting crashes when trying to access an invalid pair, make sure to get my latest version, which fixes  crash!

![IsValidCheckOnGet.jpg|956x762](upload://tSF9sIfNyhHV3ROMcL8PJxPHwBX.jpeg)

**UE4 Wiki, Plugin Download Page**
https://wiki.unrealengine.com/File:VictoryPlugin.zip

Enjoy!

:)