Files
BusyRabbit/Script/ManagedBusyRabbit/GameAbilitySystem/Ability/Common/MoveAbility.cs

26 lines
745 B
C#
Raw Normal View History

using UnrealSharp.Engine;
using UnrealSharp.Attributes;
using UnrealSharp.BusyRabbit;
using UnrealSharp.GameplayAbilities;
using UnrealSharp.CoreUObject;
namespace GameAbilitySystem.Ability.Common;
// 角色移动
[UClass]
public class UMoveAbility : UBusyGameAbility
{
protected override void ActivateAbilityFromEvent(FGameplayEventData eventData)
{
base.ActivateAbilityFromEvent(eventData);
if (UGameplayStatics.GetPlayerController(0) is ALevelPlayerController pc)
{
pc.GetCursorPosition(out FVector2D position);
if (eventData.Instigator is ABusyPawnBase pawn)
{
pawn.MovementComponent.MoveTo(position);
}
}
EndAbility();
}
}