Skip to content

Instantly share code, notes, and snippets.

View sephirot47's full-sized avatar

Victor Anton Dominguez sephirot47

View GitHub Profile
@sephirot47
sephirot47 / UE4 Pause - Resume Game .cpp
Last active January 5, 2023 11:34
UE4 Pause - Resume Game
/*
There's a function you can call to pause / resume the game in UE4:
UGameplayStatics::SetGamePaused(GetWorld(), true); //true = paused, false = resume
So you would do something like this:
*/
void Pause()
{
@sephirot47
sephirot47 / WORST CODE OF ALL MY LIFE .class
Last active January 28, 2021 08:57
WORST CODE OF ALL MY LIFE ugliest idi android parking
buttonTwoDatesPayments.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePicker = new DatePickerDialog( MainActivity.act,
new DatePickerDialog.OnDateSetListener()
@sephirot47
sephirot47 / UE4 C++ Spawn Actor from Blueprint .cpp
Last active May 26, 2023 18:24
UE4 C++ Spawn Actor from Blueprint
// MyClass.h ==============================
UClass *mBlueprintClass = nullptr;
// ==========================================
// MyClass.cpp ==============================
MyClass::MyClass()
{
static ConstructorHelpers::FObjectFinder<UBlueprint> blueprint_finder(TEXT("Blueprint'/Game/Path/To/Asset/MyBlueprint.MyBlueprint'")); // This path can be obtained from the editor doing right click + "Copy Reference"
if (blueprint_finder)
@sephirot47
sephirot47 / UE4 C++ MakeRotationFromAxes LookAt Up Vector .cpp
Created January 28, 2021 11:00
UE4 C++ MakeRotationFromAxes LookAt Up Vector
#include "Kismet/KismetMathLibrary.h"
UKismetMathLibrary::MakeRotationFromAxes( ForwardVector, RightVector, UpVector )
@sephirot47
sephirot47 / ShootThroughCrosshair.cpp
Created February 25, 2021 10:13
UE4 C++ Shoot through crosshair (or any other screen point)
const APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
// Get viewport size
int ViewportSizeX, ViewportSizeY;
PlayerController->GetViewportSize(ViewportSizeX, ViewportSizeY);
// Deproject screen point
FVector ShotStart, ShotDirection;
PlayerController->DeprojectScreenPositionToWorld(ViewportSizeX * 0.5f, ViewportSizeY * 0.5f, ShotStart, ShotDirection); // Assuming crosshair is in screen center
ShotStart += ShotDirection * 100.0f; // Offset a bit so that shot starts from gun end
@sephirot47
sephirot47 / AlternativeDrawDebugFrustum.cpp
Last active August 3, 2023 22:01
UE4 C++ Alternative DrawDebugFrustum
#pragma once
#include "CoreMinimal.h"
#include "EngineUtils.h"
#include "DrawDebugHelpers.h"
inline void DrawDebugQuad(const UWorld* World, const FVector& BotLeft, const FVector& TopLeft, const FVector& TopRight, const FVector& BotRight, const FColor& Color = FColor::Green, const bool bPersistentLines = false, const float LifeTime = -1.0f, const uint8_t DepthPriority = 0, const float Thickness = 0.0f)
{
DrawDebugLine(World, BotLeft, TopLeft, Color, bPersistentLines, LifeTime, DepthPriority, Thickness);
DrawDebugLine(World, TopLeft, TopRight, Color, bPersistentLines, LifeTime, DepthPriority, Thickness);