Skip to content

Commit f986a00

Browse files
authored
Merge pull request #106 from sentyaanko/fix_pr102_error
fixed pull request #102 errors
2 parents 8e65e0e + 3efcdec commit f986a00

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ FGameplayAbilityTargetDataHandle MakeTargetDataFromCustomName(const FName Custom
26752675
```
26762676
26772677
For getting values it requires doing type safety checking, because the only way to get values from the handle's target data is by using generic C/C++ casting for it which is *NOT* type safe which can cause object slicing and crashes. For type checking there are multiple ways of doing this(however you want honestly) two common ways are:
2678-
- Gameplay Tag(s): You can use a subclass hierarchy where you know that anytime a ceratain code architcture's functionality occurs, you can cast for the base parent type and get its gameplay tag(s) and then compare against those for casting for inherited classes.
2678+
- Gameplay Tag(s): You can use a subclass hierarchy where you know that anytime a certain code architecture's functionality occurs, you can cast for the base parent type and get its gameplay tag(s) and then compare against those for casting for inherited classes.
26792679
- Script Struct & Static Structs: You can instead do direct class comparison(which can involve a lot of IF statements or making some template functions), below is an example of doing this but basically you can get the script struct from any `FGameplayAbilityTargetData`(this is a nice advantage of it being a `USTRUCT` and requiring any inherited classes to specify the struct type in `GetScriptStruct`) and compare if its the type you're looking for. Below is an example of using these functions for type checking:
26802680
```c++
26812681
UFUNCTION(BlueprintPure)
@@ -2695,11 +2695,11 @@ FName GetCoolNameFromTargetData(const FGameplayAbilityTargetDataHandle& Handle,
26952695
// If we don't do this then it will object slice the struct and thus we have no way of making sure its that type.
26962696
if(Data->GetScriptStruct() == FGameplayAbilityTargetData_CustomData::StaticStruct())
26972697
{
2698-
return NAME_None;
2698+
// Here is when you would do the cast because we know its the correct type already
2699+
FGameplayAbilityTargetData_CustomData* CustomData = static_cast<FGameplayAbilityTargetData_CustomData*>(Data);
2700+
return CustomData->CoolName;
26992701
}
2700-
// Here is when you would do the cast because we know its the correct type already
2701-
FGameplayAbilityTargetData_CustomData* CustomData = static_cast<FGameplayAbilityTargetData_CustomData*>(Data);
2702-
return CustomData->CoolName;
2702+
return NAME_None;
27032703
}
27042704
```
27052705

@@ -3168,13 +3168,13 @@ warning C4996: 'FGameplayAbilityInputBinds::FGameplayAbilityInputBinds': Enum na
31683168
UE 5.1 deprecated using `FString` in the constructor for `BindAbilityActivationToInputComponent()`. Instead, we must pass in an `FTopLevelAssetPath`.
31693169

31703170
Old, deprecated way:
3171-
```
3171+
```c++
31723172
AbilitySystemComponent->BindAbilityActivationToInputComponent(InputComponent, FGameplayAbilityInputBinds(FString("ConfirmTarget"),
31733173
FString("CancelTarget"), FString("EGDAbilityInputID"), static_cast<int32>(EGDAbilityInputID::Confirm), static_cast<int32>(EGDAbilityInputID::Cancel)));
31743174
```
31753175
31763176
New way:
3177-
```
3177+
```c++
31783178
FTopLevelAssetPath AbilityEnumAssetPath = FTopLevelAssetPath(FName("/Script/GASDocumentation"), FName("EGDAbilityInputID"));
31793179
AbilitySystemComponent->BindAbilityActivationToInputComponent(InputComponent, FGameplayAbilityInputBinds(FString("ConfirmTarget"),
31803180
FString("CancelTarget"), AbilityEnumAssetPath, static_cast<int32>(EGDAbilityInputID::Confirm), static_cast<int32>(EGDAbilityInputID::Cancel)));

0 commit comments

Comments
 (0)