Skip to content

Instantly share code, notes, and snippets.

@luca1337
Last active February 14, 2018 23:49
Show Gist options
  • Save luca1337/78d843b20ce758a0321e4d77f1f04c0e to your computer and use it in GitHub Desktop.
Save luca1337/78d843b20ce758a0321e4d77f1f04c0e to your computer and use it in GitHub Desktop.
Simple Unreal Engine 4.x Plugin to make all Actor's that are belongs to the Viewport world to jump.
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "JumpWorldActors.h"
#define LOCTEXT_NAMESPACE "FJumpWorldActorsModule"
void FJumpWorldActorsModule::StartupModule()
{
UE_LOG(LogTemp, Display, TEXT("JumpWorldActor Plugin Loaded!"));
FConsoleCommandDelegate Delegate;
Delegate.BindRaw(this, &FJumpWorldActorsModule::JumpWorld);
IConsoleManager::Get().RegisterConsoleCommand(TEXT("JumpWorld"), TEXT("Jump All Actors Inside World!"), Delegate);
}
void FJumpWorldActorsModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
void FJumpWorldActorsModule::JumpWorld()
{
//1: Check if the GameViewport is not a bad pointer, else return
if (!GEditor->GameViewport)
return;
//Pointer to the character base class that hold Jump method
ACharacter* pCharacter = nullptr;
//Get the Viewport World
UWorld* pWorld = GEditor->GameViewport->GetWorld();
for (TObjectIterator<AActor> Itr; Itr; ++Itr)
{
AActor* FoundActor = *Itr;
//let's see if someone is ACharacter
pCharacter = Cast<ACharacter>(FoundActor);
if (!pCharacter)
continue;
if (pCharacter->GetWorld() != pWorld)
continue;
pCharacter->Jump();
}
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FJumpWorldActorsModule, JumpWorldActors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment