Download

Wiki Code Tutorials

New Tutorial, how to clear UMG Widgets between opening/closing levels.

Note: This is probably a workaround for a bug. I would Submit a Pull Request, but I’m not sure how!

**New Wiki

How to Use a Custom Skeletal Mesh Component Class with your ACharacter Extending Class!**

In this tutorial I show you how you can easily change your ACharacter class to use a custom USkeletalMeshComponent at any time during your project’s development cycle!

No custom APawn class tree required! Just a simple change to your ACharacter constructor!

Rama

Class and Line Number for your Screen and Log Messages!

Dear Community,

I am giving you easy-to-use pre-processor commands to get a UE4 String that tells you the Class Name, Function Name, and Line Number of the calling code!

Logs, Printing the Class Name, Function Name, and Line Number of your Calling Code!


**Pics**

![a51b4eb12a773cd47ef504c3015401ed5a1222f7.jpeg|1280x960](upload://nyBhSL7AeJYRaiuAA8hU6eu26hN.jpeg)

After you get my .h file below, the code for the above picture is this!



```


//~~~ Tick ~~~
void AEVCoreDefense::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	//~~~~~~~~~~~~~

	VSCREENMSG("Got Here!");  //Class and line number get printed for you! β™₯ Rama
}


```



UE_LOG Versions

I’ve also added several macros to support adding class and line number information to UE_LOG messages!



//This will print the class and line number along with the character name!
V_LOG2(YourLogCat, "Hit Character Name is",Hit.GetActor()->GetName());



**Code**

**Here is the entire file you can #include in your code base!**

I made this a file called JoyCurrentClassFuncLine.h

So you would then do this somewhere at the top of one of your core classes:



```


// Joy Class Func Line
**#include "JoyCurrentClassFuncLine.h"**


```





```


/*
	Joy String 
		Current Class, File, and Line Number!
			by Rama
 
	PreProcessor commands to get 
		a. Class name
		b. Function Name
		c. Line number 
		d. Function Signature (including parameters)
 
	Gives you a UE4 FString anywhere in your code that these macros are used!
 
	Ex: 
		You can use JOYSTR_CUR_CLASS anywhere to get a UE4 FString back telling you 
		what the current class is where you called this macro!
 
	Ex:
		This macro prints the class and line along with the message of your choosing!
		VSCREENMSG("Have fun today!");
	<3  Rama
*/
#pragma once
 
//Current Class Name + Function Name where this is called!
#define JOYSTR_CUR_CLASS_FUNC (FString(__FUNCTION__))
 
//Current Class where this is called!
#define JOYSTR_CUR_CLASS (FString(__FUNCTION__).Left(FString(__FUNCTION__).Find(TEXT(":"))) )
 
//Current Function Name where this is called!
#define JOYSTR_CUR_FUNC (FString(__FUNCTION__).Right(FString(__FUNCTION__).Len() - FString(__FUNCTION__).Find(TEXT("::")) - 2 ))
 
//Current Line Number in the code where this is called!
#define JOYSTR_CUR_LINE  (FString::FromInt(__LINE__))
 
//Current Class and Line Number where this is called!
#define JOYSTR_CUR_CLASS_LINE (JOYSTR_CUR_CLASS + "(" + JOYSTR_CUR_LINE + ")")
 
//Current Function Signature where this is called!
#define JOYSTR_CUR_FUNCSIG (FString(__FUNCSIG__))
 
 
//Victory Screen Message
// 	Gives you the Class name and exact line number where you print a message to yourself!
#define VSCREENMSG(Param1) (GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, *(JOYSTR_CUR_CLASS_LINE + ": " + Param1)) )
 
#define VSCREENMSG2(Param1,Param2) (GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, *(JOYSTR_CUR_CLASS_LINE + ": " + Param1 + " " + Param2)) )
 
#define VSCREENMSGF(Param1,Param2) (GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, *(JOYSTR_CUR_CLASS_LINE + ": " + Param1 + " " + FString::SanitizeFloat(Param2))) )
 
//UE LOG!
#define V_LOG(LogCat, Param1) 		UE_LOG(LogCat,Warning,TEXT("%s: %s"), *JOYSTR_CUR_CLASS_LINE, *FString(Param1))
 
#define V_LOG2(LogCat, Param1,Param2) 	UE_LOG(LogCat,Warning,TEXT("%s: %s %s"), *JOYSTR_CUR_CLASS_LINE, *FString(Param1),*FString(Param2))
 
#define V_LOGF(LogCat, Param1,Param2) 	UE_LOG(LogCat,Warning,TEXT("%s: %s %f"), *JOYSTR_CUR_CLASS_LINE, *FString(Param1),Param2)
 
#define V_LOGM(LogCat, FormatString , ...) UE_LOG(LogCat,Warning,TEXT("%s: %s"), 	*JOYSTR_CUR_CLASS_LINE, *FString::Printf(TEXT(FormatString), ##__VA_ARGS__ ) )


```



Enjoy!

:)

Rama

Get Float As String With Precision Using Epic’s FText Helpers

Dear Community,

I’ve updated my Get Float As String With Precision C++ wiki to use Epic’s FText helpers!

Now I am leveraging all of their awesome work to get a float as a string with any precision of your choosing, encapsulatd into an easy to use static library function.

My function also now gives you an option as to whether you want to include a leading zero for fractional numbers!

UE4 Wiki Link

Enjoy!

:slight_smile:

Rama

**Featured Wiki

Read and Write to Config Files in UE4 C++!**

In this wiki I give you code that lets you read and write to config files any time you want, more so than just using UPROPERTY(config)

You can read and write any value you want, any time, directly in UE4 C++!

End result: a Human-readible, Human-editable file that your players can tweak to adjust your game’s settings after release!

Wiki Link
A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums,Read%26_Write_to_Config_Files

:slight_smile:

Rama

How To Do Custom C++ Logic in Animation Blueprints, Every Tick!

In this wiki I show you how you can add custom project-level C++ code to your Animation Blueprints!

This is code that you can run every animation tick!

This allows you as the C++ programmer to support your entire time by doing intense math calculations in C++, which is much faster than in BP!

This also lets you utiilze your entire C++ code base and custom data structures without having to expose it all to BP so that the animation blueprint can use it in the event graph!

Custom C++ Logic for Animation Blueprints

Enjoy!

:slight_smile:

Rama

Thank you Rama for your great work! :slight_smile:

Hee hee!

You’re welcome!

Have fun today!

:slight_smile:

Rama

**Creating Dynamic Physics Constraints During Runtime

My Physics Library Functions Included!**

:slight_smile:

Rama

Thanks for the code tutorials!!!

You’re welcome danjedi!

[FONT=Comic Sans MS]Welcome to the UE4 Forums!

:slight_smile:

Rama

thank you for your effort, but I really hope the material can be organized more like a book, with a proper learning order.

Entry Level Guide to UE4

I am indeed working on a UE4 C++ book, so great idea :slight_smile:

Until then I recommend everyone start with:

Entry Level Guide to UE4

Now available in Russian!

:slight_smile:

Rama

Blueprint Native Event

Dear Community,

Here is my new wiki tutorial on Blueprint Native Events!

BP Native Events allow you to have a core C++ implementation that can be overridden / extended in BP by your team mates!

Blueprint Native Events

:slight_smile:

Rama

Before I invest time into this, will the tutorials on the first post work with 4.8?

If you find a tutorial is not compiling in 4.8 just let me know!

If you find any uses of



(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)


replace it with



(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)


Epic has been providing absolutely wonderful compiler error / deprecation warnings since about 4.6, so most likely if something is out of date, the compiler will tell you exactly what to do.

:slight_smile:

Rama

Animated Vertex Positions With Movement Velocity Correction

Dear Community,

I’ve released a new wiki on how you can obtain animated vertex positions of character meshes!


**C++ Code For You**

Here's the code I just finished writing to obtain accurate animated character vertex positions!



```


bool UVictoryBPFunctionLibrary::AnimatedVertex__GetAnimatedVertexLocations(
	USkeletalMeshComponent* Mesh, 
	TArray<FVector>& Locations,
	bool PerformPawnVelocityCorrection
){
	if(!Mesh || !Mesh->SkeletalMesh)  
	{
		return false;
	}

	//~~~~~~~~~~~~~
	Locations.Empty(); 
	//~~~~~~~~~~~~~
	 
	Mesh->ComputeSkinnedPositions(Locations);
	
	FTransform ToWorld = Mesh->GetComponentTransform();
	FVector WorldLocation = ToWorld.GetLocation();
	
	//Pawn Velocity Correction
	UPawnMovementComponent* MovementComp = nullptr;
	if(PerformPawnVelocityCorrection)
	{
		APawn* Pawn = Cast<APawn>(Mesh->GetOwner());
		MovementComp = (Pawn) ? Pawn->GetMovementComponent() : NULL;
	}
	bool DoVelocityCorrection = PerformPawnVelocityCorrection && MovementComp;
	//Pawn Velocity Correction
	 
	for(FVector& Each : Locations)
	{
		Each = WorldLocation + ToWorld.TransformVector(Each);
		if(DoVelocityCorrection)
		{
			Each += MovementComp->Velocity * FApp::GetDeltaTime();
		} 
	} 
	
	return true;
}


```



Enjoy!

:)

Rama

New Wiki Tutorial: How to create a blueprint node for sorting an array of Actors by field value.

Awesome!..

Thanks for sharing Nimgoble!

:slight_smile:

:slight_smile:

:slight_smile:

Rama