BlueprintCallable UFUNCTION¶
Type Mapping¶
Mapping Fundamental Types¶
Blueprint |
C++ |
---|---|
Float |
float |
- |
double |
Integer |
int32 |
- |
uint32 |
Integer64 |
int64 |
- |
uint64 |
Bool |
bool |
Mapping Utility Types¶
Blueprint FString
Blueprint |
C++ |
---|---|
String |
FString |
Name |
FName |
Vector |
FVector |
Rotator |
FRotator |
Transform |
FTransform |
Mapping Object Types¶
Blueprint |
C++ |
---|---|
Object |
UObject* |
Actor |
AActor* |
ActorComponent |
UActorComponent* |
Creating C++ Function¶
Add to Grabber.h the below:
UFUNCTION(BlueprintCallable, BlueprintPure)
FVector GetMaxGrabLocation() const;
Ctrl+. and create definition.
Also tip: Ctrl-K Ctrl-O to swtich between .cpp and .h
Add the #include:
#include "Kismet/KismetMathLibrary.h"
Add the code:
FVector UGrabber::GetMaxGrabLocation() const
{
return GetComponentLocation() + UKismetMathLibrary::GetForwardVector(GetComponentRotation()) * MaxGrabDistance;
}
Ctrl-Shift-B to compile and we’ll see the blueprint now complains because grabber already exists.
Now check references and see that all references have already been replaced with the C++ version. Simply delete the Blueprint version and compile.
Now you should still be able to grab the pumpkin, but we have replaced the BP function with a C++ one.