C# 使用正则表达式(dotnetcore)_"regex rx = new regex(@\"
赞
踩
可以通过自定义一些ConsoleVariables来控制程序的执行方式,便于调试,不会在实际打包中出现
// 可在CPP文件中进行如下声明
static TAutoConsoleVariable<T> CVarName(TEXT("YourGameName.VarName"),true,TEXT("Hint"),ECVF_Cheat);
CVarName.GetValueOnGameThread() // 获取数据
好处:
FTimerHandle TimerHandle_RespawnPlayer;
FTimerDelegate TimerDelegate_RespawnPlayer;
TimerDelegate_RespawnPlayer.BindUFunction(this,"RespawnTimerElapsed" /* 函数名 */,Player->GetController() /* 函数的参数 */);
float RespawnDelay = 2.0f;
GetWorldTimerManager().SetTimer(TimerHandle_RespawnPlayer,TimerDelegate_RespawnPlayer,RespawnDelay,false);
// UE可以使用类似于C语言Printf的方式打印log
UE_LOG(LogTemp,Log,TEXT("OnActorKilled: Victim: %s, Killer: %s"),*GetNameSafe(Victim),*GetNameSafe(Killer));
GitHub: https://github.com/yufeige4/ActionRoguelike
// GGameplayFunctionLibrary.h UENUM(BlueprintType) enum class EAIState : uint8 { InCombat UMETA(DisplayName = "战斗状态"), OutCombat UMETA(DisplayName = "脱战状态"), Died UMETA(DisplayName = "死亡") }; UCLASS() class ACTIONROGUELIKE_API UGGameplayFunctionLibrary : public UBlueprintFunctionLibrary { GENERATED_BODY() public: UFUNCTION(BlueprintCallable, Category = "Gameplay") static bool ApplyDamage(AActor* FromActor, AActor* ToActor, float DamageAmount); UFUNCTION(BlueprintCallable, Category = "Gameplay") static bool ApplyDirectionalDamage(AActor* FromActor, AActor* ToActor, float DamageAmount, const FHitResult& HitResult); };
// GGameplayFunctionLibrary.h bool UGGameplayFunctionLibrary::ApplyDamage(AActor* FromActor, AActor* ToActor, float DamageAmount) { UGAttributeComponent* AttributeComp = UGAttributeComponent::GetAttributeComponent(ToActor); if(AttributeComp) { return AttributeComp->ApplyHealthChange(FromActor,DamageAmount); } return false; } bool UGGameplayFunctionLibrary::ApplyDirectionalDamage(AActor* FromActor, AActor* ToActor, float DamageAmount, const FHitResult& HitResult) { if(ApplyDamage(FromActor,ToActor,DamageAmount)) { auto HitComp = HitResult.GetComponent(); if(HitComp && HitComp->IsSimulatingPhysics(HitResult.BoneName)) { float ImpulseMagnitude = 300000.0f; FVector ImpulseDirection = -HitResult.ImpactNormal; HitComp->AddImpulseAtLocation(ImpulseDirection*ImpulseMagnitude,HitResult.ImpactPoint,HitResult.BoneName); } return true; } return false; }
Note: 目前MagicProjectile的受击仍有问题,后续将增加MagicProjectile的碰撞通道来正式解决此问题,临时使用修改碰撞属性来暂时修复
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。