UE4 C++ AI实现跳跃(上下平台)
NavLinkProxy
- PointLink: 点对点,不提供可处理的事件
- SmartLink:提供可处理的事件,当AI到达Link位置时,可以接受函数
通过Receive Smart Link Reached事件进行绑定函数操作
实现简单的跳跃
通过接口,定义函数,在AI基类中进行实现。
主要通过两个函数实现
UGameplayStatics::SuggestProjectileVelocity_CustomArc() //通过起点和终点以及发射角度计算速度
LaunchCharacter()//以一定速度将Character发射
源码中用于计算速度就是以下公式

void AXAI_Character::JumpToLoc_Implementation(FVector Location)
{
UE_LOG(LogTemp, Warning, TEXT("JumpToLoc"));
//PlayAnimMontage(JumpMontage);
FVector LaunchVelocity;
FVector EndLoc = FVector{ Location.X,Location.Y,Location.Z + 250.f };
UGameplayStatics::SuggestProjectileVelocity_CustomArc(
GetWorld(),
LaunchVelocity,
GetActorLocation(),
EndLoc,
0.0f,
0.5f
);
//以一定速度将Actor发射出去
LaunchCharacter(LaunchVelocity, true, true);
}

浙公网安备 33010602011771号