Ooooh
hee hee
no that’s not an error
that’s normal
BP Libraries are made of static functions based on a non-instanced UObject extended class called BlueprintFunctionLibrary.
you can’t call getworld() from such a function.
you have to pass in an AActor or get an actor using Object Iterator
You can then use all GetWorld Functions since it is likely they will share same world in the in-game instance.
Here’s some examples from my BP Library
case 1: get from input actor
case 2: use object iterator to find a player controller, assumes not used in Editor, only in game instance
Here’s link to my BP library, I included the CPP Source code in my plugin download
http://forums.epicgames.com/threads/977316-(33)Rama-s-Blueprint-Nodes-Plugin-For-You!-Float-as-Str-w-Precision-Ragdoll-Traces
#1
void UVictoryBPFunctionLibrary::Draw__Thick3DLineFromCharacterSocket(AActor* TheCharacter, const FVector& EndPoint, FName Socket, FLinearColor LineColor, float Thickness, float Duration)
{
ACharacter * AsCharacter = Cast(TheCharacter);
if (!AsCharacter) return;
if (!AsCharacter->Mesh) return;
//~~~~~~~~~~~~~~~~~~~~
//Get World
UWorld* TheWorld = AsCharacter->GetWorld();
if (!TheWorld) return;
//~~~~~~~~~~~~~~~~~
const FVector SocketLocation = AsCharacter->Mesh->GetSocketLocation(Socket);
DrawDebugLine(
TheWorld,
SocketLocation,
EndPoint,
FColor(LineColor),
false,
Duration,
0,
Thickness
);
}
#2
void UVictoryBPFunctionLibrary::Draw__Thick3DLineFromSocket(USkeletalMeshComponent* Mesh, const FVector& EndPoint, FName Socket, FLinearColor LineColor, float Thickness, float Duration)
{
if (!Mesh) return;
//~~~~~~~~~~~~~~
//Get an actor to GetWorld() from
TObjectIterator Itr;
if (!Itr) return;
//~~~~~~~~~~~~
//Get World
UWorld* TheWorld = Itr->GetWorld();
if (!TheWorld) return;
//~~~~~~~~~~~~~~~~~
const FVector SocketLocation = Mesh->GetSocketLocation(Socket);
DrawDebugLine(
TheWorld,
SocketLocation,
EndPoint,
FColor(LineColor),
false,
Duration,
0,
Thickness
);
}
Hope this fully resolves your issue!
Rama