# ProjectionInfo
# 说明
用于表示点到线段的投影信息的结构体,包含投影点是否在线段上、线段上的投影点坐标等信息。
# 如何使用
// 定义线段的起点和终点
Vector segmentStart = ObjectManager::Player()->Position();
Vector segmentEnd = segmentStart.Extend(targetPosition, 500.f);
// 计算目标点到线段的投影
Vector pointToProject = enemy->Position();
ProjectionInfo projection = pointToProject.ProjectOn(segmentStart, segmentEnd);
// 使用投影结果
if (projection.IsOnSegment)
{
// 投影点在线段上
Vector projectedPoint = projection.SegmentPoint;
// 计算目标点到线段的垂直距离
float distanceToLine = pointToProject.Distance(projectedPoint);
// 判断目标是否在技能范围内
if (distanceToLine <= 60.f) // 技能宽度为120,半径为60
{
// 目标在线性技能的影响范围内
ObjectManager::Player()->CastSpell(eSpellSlot::Q, segmentEnd);
}
// 计算投影点在线段上的相对位置
float projectionDistance = segmentStart.Distance(projectedPoint);
float segmentLength = segmentStart.Distance(segmentEnd);
float projectionPercentage = projectionDistance / segmentLength;
// 根据投影位置做决策
if (projectionPercentage > 0.7f)
{
// 目标接近线段终点
}
}
else
{
// 投影点不在线段上,可能在线的延长线上
Vector linePoint = projection.LinePoint;
// 可能需要调整技能方向以命中目标
}
# Properties
属性名 | 类型 | 描述 |
---|---|---|
IsOnSegment | bool | 投影点是否在线段上 |
LinePoint | Vector | 线上的投影点 |
SegmentPoint | Vector | 线段上的投影点 |
← PredictionOutput 颜色函数 →