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 UPROPERTY UFUNCTION
Created June 28, 2015 20:52
UE4 UPROPERTY UFUNCTION
UPROPERTY(EditAnywhere, Category=Pawn)
float speed;
UFUNCTION(BlueprintCallable, Category=Attachment)
void do() { }
@sephirot47
sephirot47 / GLSL Raymarch ShaderToy tutorial and example code
Created June 29, 2015 12:28
GLSL Raymarch ShaderToy tutorial and example code
/*
a shader executes per pixel
so every thing you see here is he function for every pixel
raymarching is in principe a function that finds the closest point to any surface in the world
then we move our point by that distance and use the same function,
the function will probably be closer to an object in the world every time
and after about 40 to 200 iterations you'll either have found an object or
missed them all into infinity
@sephirot47
sephirot47 / gist:8e475b090d4314b6a628
Created June 30, 2015 14:32
UE4 Get Viewport / Screen Size and Center
/*
IMPORTANT!
In order to be able to use this functions, in the file "YourProject.h" change this:
#include "EngineMinimal.h"
For this:
#include "Engine.h"
@sephirot47
sephirot47 / UE4 Set-Change Material .cpp
Last active January 28, 2021 09:01
UE4 Set-Change Material
void ChangeMaterial(UMaterial *material)
{
TArray<UStaticMeshComponent*> meshes;
GetComponents<UStaticMeshComponent>(meshes); //Get all the mesh components
for (UStaticMeshComponent *mesh : meshes)
mesh->SetMaterial(0, material); //For each mesh component, set the material (the 0 is the element index of the material)
}
@sephirot47
sephirot47 / UE4 Interesting documentation links
Last active August 29, 2015 14:24
UE4 Interesting documentation links
@sephirot47
sephirot47 / UE4 Little UMG or Set UMG size or Set UMG Position .cpp
Last active January 28, 2021 09:01
UE4 Little UMG or Set UMG size or Set UMG Position
/*
The key to this is to make a normal UMG, but use the Blueprint function SetAnchors, where Minimum and Maximum inputs to this function go from 0.0 -> 1.0 (normalized screen size).
For example, if I want to put an UMG which only occupies the right bottom corner of the screen, I would use:
SetAnchors, where Minimum = (0.5, 0.5) and Maximum = (1.0, 1.0)
*/
@sephirot47
sephirot47 / UE4 C++ Set Object Type or Set Collision Channel Type .cpp
Last active July 14, 2023 12:33
UE4 C++ Set Object Type or Set Collision Channel Type
/*
Ok, so you want to change your Object Type (or collision channel) to a custom channel in runtime.
But there's a problem, it seems UE4 doesn't support this yet, but there's a workaround hehe :)
For example, imagine you create the ObjectType Building.
Now, imagine you want to change the ObjectType of all the StaticMeshComponents of the object OBJECT (from WorldStatic to Building, for example).
You can try something like this:
*/
@sephirot47
sephirot47 / UE4 Draw Debug Line .cpp
Last active August 21, 2023 07:05
UE4 Draw Debug Line
#include "DrawDebugHelpers.h"
DrawDebugLine(GetWorld(), traceStart, traceEnd, FColor::Green, true, 1.0f);
@sephirot47
sephirot47 / UE4 Get Camera Location or Position and Forward Vector .cpp
Last active February 7, 2025 10:14
UE4 Get Camera Location or Position and Forward Vector (useful for Tracing)
APlayerCameraManager *camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;
FVector camLocation = camManager->GetCameraLocation();
FVector camForward = camManager->GetCameraRotation().Vector();
@sephirot47
sephirot47 / UE4 OnBeginOverlap - OnEndOverlap (Collision stuff) .cpp
Last active September 30, 2024 14:57
UE4 OnBeginOverlap - OnEndOverlap (Collision stuff)
// For Components =================================
UFUNCTION()
void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UFUNCTION()
void OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
// Register events in BeginPlay
OnComponentBeginOverlap.AddDynamic(this, &MyClass::OnBeginOverlap); //Register the BeginOverlap event
OnComponentEndOverlap.AddDynamic(this, &MyClass::OnEndOverlap); //Register the EndOverlap event
// =================================================