• CinemachinePath


    CinemachinePathBase:

    • public float FindClosestPoint (Vector3 p, int startSegment, int searchRadius, int stepsPerSegment);
      (en) 找到路径上距离目标点(世界坐标系)最近的点。

      • p: 目标点(世界坐标系)
      • startSegment: 在哪一路段开始搜索。路段指两个 waypoint 之间的一段路径
      • searchRadius: 参数startSegment两侧要搜索的段数-1表示没有限制,即搜索整个路径
      • stepsPerSegment: 将一路段分割成许多直线来搜索它。数字越高,结果越准确,但数字越大,性能也相应地越慢
      • 返回值: 路径上最接近目标点的位置,以 PositionUnits.PathUnits 为单位, 非 PositionUnits.Distance
    • public Vector3 EvaluatePositionAtUnit(float pos, CinemachinePathBase.PositionUnits units);
      (en) 获取路径上某点的世界坐标系位置

      • pos: 沿着路径的位置,不需要标准化
      • units: 参数pos使用的单位
    • public float FromPathNativeUnits(float pos, CinemachinePathBase.PositionUnits units);
      (en) 将路径位置从 PositionUnits.PathUnits 转换为所需单位。如果距离缓存无效,则调用此命令将触发路径距离缓存的潜在代价高昂的重新生成

      • pos: 需要转换的 PositionUnits.PathUnits
      • units: 目标单位 PositionUnits

    Enum CinemachinePathBase.PositionUnits:

    • Distance: 沿着路径的距离
    • Normalized: 标准化单位,0是路径的起点,1是终点
    • PathUnits: 0为第一个航路点,0.5为第一与第二个航路点的中间,1为第二个航路点,以此类推

    例:查找 CinemachinePath 路径上距离玩家最近的点

    float playerPosUnits = path.FindClosestPoint(player.position,0,-1,0);
    Debug.Log($"playerPosUnits:{playerPosUnits}");
    Vector3 playerPosOnPath = smoothPath.EvaluatePosition(playerPosUnits); // 玩家在路径上的世界坐标
    
  • 相关阅读:
    python3+requests接口自动化-其他接口封装
    python3+requests接口自动化-登陆模块封装
    python3+requests接口自动化-测试登陆
    python3+requests接口自动化-日志封装
    python3+requests接口自动化-配置文件
    python3接口自动化-run_all_case
    python3+requests接口自动化session操作
    selenium自动化-数据驱动2
    js弹出对话框
    "System.StackOverflowException"类型的未经处理的异常在SharingPlatform.dll中发生
  • 原文地址:https://www.cnblogs.com/kingBook/p/15928585.html
Copyright © 2020-2023  润新知