This file contains 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
- GameMode, make sure none of them is null | |
- Null pointer exceptions | |
- Having instantiated in the level the same PlayerBP than the one in GameMode | |
(so when the game starts the GameMode puts another one and it gets duplicated ) | |
- Having BAD CODE(code that can cause a crash), even on startup. Ye, if u have bad code it can crash on startup!!! UE4 does some sort of prebuild or something. Beware of putting code on the constructor that must go in the BeginPlay instead, this happened to me <3 |
This file contains 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
UComponentType *myComponent; | |
TArray<UComponentType*> comps; | |
actor->GetComponents(comps); | |
if (comps.Num() > 0) myComponent = comps[0]; |
This file contains 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
//For every actor in this level... | |
for (TActorIterator<AActor> actor(GetWorld()); actor; ++actor) | |
{ | |
//Do whatever you want with your actor | |
actor->BlahBlah(); | |
} |
This file contains 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
//Input name //Function to handle the input | |
this->InputComponent->BindAxis("MoveForward", this, &UMyActor::HandleVerticalAxis); | |
void UMyActor::HandleVerticalAxis(float v) | |
{ | |
//v is the float value for the input | |
} |
This file contains 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
//Supose we are inside a Component ACTOR OF THE COMP. | |
AREMHUD *hud = Cast<AREMHUD>(UGameplayStatics::GetPlayerController( this->GetOwner(), 0)->GetHUD()); | |
//Custom HUD class: AREMHUD |
This file contains 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
//Pars: id, seconds, color, text | |
GEngine->AddOnScreenDebugMessage(0, 1, FColor::Red, TEXT("HI")); | |
GEngine->AddOnScreenDebugMessage(76867, 3, FColor::MakeRandomColor(), FString::FromInt(8572)); | |
GEngine->AddOnScreenDebugMessage(76867, 5, FColor::MakeRandomColor(), FString::SanitizeFloat(3.141592f)); | |
This file contains 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
//En el constructor (no el BeginPlay) | |
UTexture2D *texture; | |
static ConstructorHelpers::FObjectFinder<UTexture2D> Texture(TEXT("/Game/StarterContent/Textures/T_Spark_Core.T_Spark_Core")); | |
texture = Texture.Object; |
This file contains 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
UGameplayStatics::GetPlayerController(actor, 0) |
This file contains 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
//From the actor's viewport (camera) | |
FVector2D result; | |
UGameplayStatics::GetPlayerController(actor, 0)->ProjectWorldLocationToScreen(pointInWorld, result); | |
//result now has the screen point(x,y) |
This file contains 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
character->InputComponent->BindAction("Jump", IE_Pressed, this, &AMyCharacter::HandleJump); | |
character->InputComponent->BindAction("Jump", IE_Released, this, &AMyCharacter::HandleJump); |
OlderNewer