Last active
August 9, 2019 06:12
-
-
Save kkabdol/ccc8c23e7f4e6932c36ff31debdfee4c to your computer and use it in GitHub Desktop.
UE4 Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////////////////////////// | |
// Display the gamepad buttons in the editor with XBox or PS4 names | |
////////////////////////////////////////////////////////////////////////////////////////// | |
UEditorExperimentalSettings > TEnumAsByte < EConsoleForGamepadLabels::Type > ConsoleForGamepadLabels // Specify which console-specific nomenclature to use for gamepad label text | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Character Cheat-sheet | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Component Values | |
Character > Jump Max Hold Time | |
Character > Jump Max Count | |
Character Movement Component > Character Movement: Walking > Max Step Height | |
Character Movement Component > Character Movement: Walking > Walkable Floor Angle | |
Character Movement Component > Character Movement: Jumping / Falling > Air Control | |
// BP Functions | |
AddMovementValue() // for RM animations like rolling | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Dodge : https://www.youtube.com/watch?v=UkQiCZ5MC4Q | |
////////////////////////////////////////////////////////////////////////////////////////// | |
LaunchCharacter() // Blueprints | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Enum for TArray | |
// https://wiki.unrealengine.com/Enums_For_Both_C%2B%2B_and_BP | |
////////////////////////////////////////////////////////////////////////////////////////// | |
UENUM( BlueprintType ) | |
enum class ESkills : uint8 | |
{ | |
None UMETA( DisplayName = "None" ), | |
ImprovedHealth UMETA( DisplayName = "Improved Health" ), | |
AdvancedHealth UMETA( DisplayName = "Advanced Health" ), | |
SuperiorHealth UMETA( DisplayName = "Superior Health" ), | |
Undefined UMETA( DisplayName = "Undefined" ), | |
}; | |
class ANIMATION101_API APlayableCharacter : public AIKCharacter | |
{ | |
... | |
UPROPERTY( EditDefaultsOnly, BlueprintReadWrite, Category = "Gameplay|Attributes" ) | |
TArray<ESkills> AcquiredSkills; | |
... | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Log | |
// https://wiki.unrealengine.com/Logs,_Printing_Messages_To_Yourself_During_Runtime | |
////////////////////////////////////////////////////////////////////////////////////////// | |
UE_LOG( LogTemp, Warning, TEXT( "Your Message" ) ); | |
UE_LOG( LogTemp, Warning, TEXT( "Actor Name %s" ), *( GetOwner()->GetName() ) ); | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Git Command to resolve conflict (unrelated-histories) | |
////////////////////////////////////////////////////////////////////////////////////////// | |
git pull origin master --allow-unrelated-histories | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Get Time | |
////////////////////////////////////////////////////////////////////////////////////////// | |
FPlatformTime::Seconds() | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Clamp | |
////////////////////////////////////////////////////////////////////////////////////////// | |
FMath::Clamp(x, min, max) | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Deproject from screen to world in PlayerController | |
////////////////////////////////////////////////////////////////////////////////////////// | |
bool APlayerController::DeprojectScreenPositionToWorld(float ScreenX, float ScreenY, FVector& WorldLocation, FVector& WorldDirection) const | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Get viewport size in PlayerController | |
////////////////////////////////////////////////////////////////////////////////////////// | |
void APlayerController::GetViewportSize(int32& SizeX, int32& SizeY) const; | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Casting | |
////////////////////////////////////////////////////////////////////////////////////////// | |
ATank* ATankAIController::GetPlayerTank() const | |
{ | |
auto Tank = Cast<ATank>( GetWorld()->GetFirstPlayerController()->GetPawn() ); | |
return Tank; | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Line Tracing | |
////////////////////////////////////////////////////////////////////////////////////////// | |
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | |
... | |
/// Draw a red trace in the world to visualise Grabber's reach | |
const FVector LineTraceStart = GetOwner()->GetActorLocation(); | |
const FVector LineTraceEnd = LineTraceStart + GetOwner()->GetActorRotation().Vector() * Reach; | |
DrawDebugLine( | |
GetWorld(), | |
LineTraceStart, | |
LineTraceEnd, | |
FColor::Red, | |
false, | |
0.0f, | |
0.0f, | |
10.0f | |
); | |
/// Setup query parameters | |
FCollisionQueryParams TraceParameters( FName( TEXT( "" ) ), false, GetOwner() ); | |
/// Line-trace (AKA ray-cast) out to reach distance | |
FHitResult Hit; | |
GetWorld()->LineTraceSingleByObjectType( | |
OUT Hit, | |
LineTraceStart, | |
LineTraceEnd, | |
FCollisionObjectQueryParams( ECollisionChannel::ECC_PhysicsBody ), | |
TraceParameters | |
); | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Out parameter macro | |
////////////////////////////////////////////////////////////////////////////////////////// | |
#define OUT | |
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | |
{ | |
... | |
FVector PlayerViewpointLocation; | |
FRotator PlayerViewpointRotator; | |
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint( | |
OUT PlayerViewpointLocation, | |
OUT PlayerViewpointRotator | |
); | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Polling Trigger Volume | |
////////////////////////////////////////////////////////////////////////////////////////// | |
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | |
{ | |
... | |
if ( PressurePlate->IsOverlappingActor( ActorThatOpens ) ) | |
{ | |
... | |
} | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Get Player Pawn | |
////////////////////////////////////////////////////////////////////////////////////////// | |
void UOpenDoor::BeginPlay() | |
{ | |
... | |
APawn* FirstPlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn(); | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Lerp Example | |
////////////////////////////////////////////////////////////////////////////////////////// | |
void UOpenDoor::OpenDoor() | |
{ | |
const float OpenAngle = 90.0f; | |
AActor* Owner = GetOwner(); | |
FRotator NewRotator = FRotator( 0.0f, OpenAngle, 0.0f ); | |
Owner->SetActorRotation( FMath::Lerp( Owner->GetActorRotation(), NewRotator, 0.025f ) ); | |
} | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Visual Studio 2017 Extensions | |
////////////////////////////////////////////////////////////////////////////////////////// | |
- VSColorOutput : Visual Studio Marketplace | |
- UnrealVS Extension : "UE_4.19\Engine\Extras\UnrealVS\VS2017\UnrealVS.vsix" | |
- UE4Snippets : Visual Studio Marketplace | |
- SpecifierTool : Visual Studio Marketplace | |
- Indentation : github.com/hackalyze/ue4-vs-extensions | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Blueprint Editor | |
////////////////////////////////////////////////////////////////////////////////////////// | |
Alt + LMB : Break the link | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Unreal Editor Shortcut | |
////////////////////////////////////////////////////////////////////////////////////////// | |
L + Double LMB : Place a point light | |
F8 : Eject from Preview | |
F11 : Maximize Play Window in Editor | |
Shift + B : Select all the faces of the brush object | |
Ctrl + B : Browse to in Content Browser | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Visual Studio Shortcut | |
////////////////////////////////////////////////////////////////////////////////////////// | |
Ctrl+K, Ctrl+O : Switch between header and source | |
Shift + Ctrl + Space : Parameter Info | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// .gitattributes | |
////////////////////////////////////////////////////////////////////////////////////////// | |
# Unreal Engine file types. | |
*.uasset filter=lfs diff=lfs merge=lfs -text | |
*.umap filter=lfs diff=lfs merge=lfs -text | |
# Raw Content file types. | |
*.fbx filter=lfs diff=lfs merge=lfs -text | |
*.3ds filter=lfs diff=lfs merge=lfs -text | |
*.psd filter=lfs diff=lfs merge=lfs -text | |
*.png filter=lfs diff=lfs merge=lfs -text | |
*.mp3 filter=lfs diff=lfs merge=lfs -text | |
*.wav filter=lfs diff=lfs merge=lfs -text | |
*.xcf filter=lfs diff=lfs merge=lfs -text | |
*.jpg filter=lfs diff=lfs merge=lfs -text | |
# Anything in `/RawContent` dir. | |
/RawContent/**/* filter=lfs diff=lfs merge=lfs -text | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// .gitignore | |
////////////////////////////////////////////////////////////////////////////////////////// | |
# Visual Studio 2015 user specific files | |
.vs/ | |
# Visual Studio 2015 database file | |
*.VC.db | |
# Compiled Object files | |
*.slo | |
*.lo | |
*.o | |
*.obj | |
# Precompiled Headers | |
*.gch | |
*.pch | |
# Compiled Dynamic libraries | |
*.so | |
*.dylib | |
*.dll | |
# Fortran module files | |
*.mod | |
# Compiled Static libraries | |
*.lai | |
*.la | |
*.a | |
*.lib | |
# Executables | |
*.exe | |
*.out | |
*.app | |
*.ipa | |
# These project files can be generated by the engine | |
*.xcodeproj | |
*.xcworkspace | |
*.sln | |
*.suo | |
*.opensdf | |
*.sdf | |
*.VC.db | |
*.VC.opendb | |
# Precompiled Assets | |
SourceArt/**/*.png | |
SourceArt/**/*.tga | |
# Binary Files | |
Binaries/* | |
Plugins/*/Binaries/* | |
# Builds | |
Build/* | |
# Whitelist PakBlacklist-<BuildConfiguration>.txt files | |
!Build/*/ | |
Build/*/** | |
!Build/*/PakBlacklist*.txt | |
# Don't ignore icon files in Build | |
!Build/**/*.ico | |
# Built data for maps | |
*_BuiltData.uasset | |
# Configuration files generated by the Editor | |
Saved/* | |
# Compiled source files for the engine to use | |
Intermediate/* | |
Plugins/*/Intermediate/* | |
# Cache files for the editor to use | |
DerivedDataCache/* | |
# StarterContent | |
Content/StarterContent/Textures | |
Content/StarterContent/HDRI | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// Best practice to create a new project for github | |
////////////////////////////////////////////////////////////////////////////////////////// | |
Link : https://wiki.unrealengine.com/GitHub_Desktop_to_manage_your_project | |
1. Create a project in GitHub with .gitignore and .gitattributes file. | |
2. Clone to a folder. | |
3. Create a UE4 project in that folder. | |
4. Commit the UE4 project. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment