<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      UE5中實現鼠標點擊移動


      在PlayerController中

      變量

      UPROPERTY(VisibleAnywhere,Category = "Input")
      TObjectPtr<USplineComponent> Spline;
      //是否在自動尋路
      bool bAutoRunning = false;
      //鼠標已按住時間
      float FollowTime = 0.f;
      //鼠標按住時間
      UPROPERTY(EditAnywhere)
      float HoldTimeToMove = 0.5f;
      //到目的地距離
      UPROPERTY(EditAnywhere)
      float AutoRunningAcceptRadius = 50.f;
      //目的地
      FVector CachedDestination = FVector::Zero();

       

       

      鼠標按下時

      void ADiabloPlayerController::AbilityInputTagPressed()
      {
          bAutoRunning = false;
      }

       

      鼠標松開時,如果是點擊事件,則按照路徑點繪制樣條線

      void ADiabloPlayerController::AbilityInputTagReleased()
      {
              APawn* ControlledPawn = GetPawn();
              if (FollowTime < HoldTimeToMove && ControlledPawn)
              {
                  //尋蹤玩家到目的地的路徑
                  if (UNavigationPath* Path = UNavigationSystemV1::FindPathToLocationSynchronously(this,ControlledPawn->GetActorLocation(),CachedDestination))
                  {
                      Spline->ClearSplinePoints();
                      //路徑上的點
                      TArray<FVector> Points = Path->PathPoints;
                      if (!Points.IsEmpty())
                      {
                          for (FVector PathPoint : Points)
                          {
                              //在樣條線上加點
                              Spline->AddSplinePoint(PathPoint,ESplineCoordinateSpace::World);
                              DrawDebugSphere(GetWorld(),PathPoint,8.f,8,FColor::Green,false,5.f);
                          }
                          //最后點算做目的地
                          CachedDestination = Points.Last();
                          bAutoRunning = true;
                      }
                  }
              }
              FollowTime = 0;
      }

       

      按住鼠標時,朝著鼠標方向移動

      void ADiabloPlayerController::AbilityInputTagHeld()
      {
              //按住時間累積
              FollowTime += GetWorld()->GetDeltaSeconds();
              //得到點擊的目的地
              FHitResult HitResult;
              if (GetHitResultUnderCursor(ECC_Visibility,false,HitResult))
              {
                  CachedDestination = HitResult.ImpactPoint;
              }
              APawn* ControlledPawn = GetPawn();
              if (ControlledPawn)
              {
                  //移動到目的地
                  FVector Direction = CachedDestination - ControlledPawn->GetActorLocation();
                  ControlledPawn->AddMovementInput(Direction);
              }
      }

       

      Tick事件中

      void ADiabloPlayerController::AutoRun()
      {
          if (!bAutoRunning)
          {
              return;
          }
           APawn* CharacterPawn = GetPawn();
          if (CharacterPawn)
          {
              //找到玩家到樣條線最近的點
              FVector LocationOnSpline = Spline->FindLocationClosestToWorldLocation(CharacterPawn->GetActorLocation(),ESplineCoordinateSpace::World);
              //獲得樣條線上該點的朝向
              FVector Direction = Spline->FindDirectionClosestToWorldLocation(LocationOnSpline,ESplineCoordinateSpace::World);
              CharacterPawn->AddMovementInput(Direction);
              //計算到目的地距離
              float Distance = (LocationOnSpline - CachedDestination).Length();
              //到達目的地則停止尋路
              if (Distance<= AutoRunningAcceptRadius)
              {
                  bAutoRunning = false;
              }
          }
      }

       

       
      posted @ 2025-04-15 18:10  幾個Ak  閱讀(118)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产精品久久久天天影视香蕉| AV最新高清无码专区| 国产粉嫩一区二区三区av| 办公室强奷漂亮少妇视频| 日本一卡2卡3卡四卡精品网站| 亚洲欧美高清在线精品一区二区| 久久精品av国产一区二区| 日日躁狠狠躁狠狠爱| 宾川县| 国产日韩乱码精品一区二区 | 91精品乱码一区二区三区| 欧美日韩综合网| 精品国产中文字幕懂色| 无码熟妇人妻av在线电影| 久久九九精品国产免费看小说| 多伦县| 久操热在线视频免费观看 | 熟女少妇精品一区二区| аⅴ天堂国产最新版在线中文| 农村乱色一区二区高清视频| 国产亚洲av夜间福利香蕉149| 亚洲色成人一区二区三区人人澡人人妻人人爽人人蜜桃麻豆 | 日韩欧美在线综合网另类| 欧美午夜成人片在线观看| 濮阳县| 国产乱码日韩精品一区二区| 亚洲欧美人成网站在线观看看| 五月婷婷久久草| 亚洲精品自产拍在线观看动漫 | 东京热一精品无码av| 婷婷色爱区综合五月激情韩国| 临桂县| 亚洲AV无码不卡在线播放| 亚洲AV无码专区亚洲AV桃 | 日韩人妻精品中文字幕| 国产精品麻豆欧美日韩ww| 国内视频偷拍久久伊人网| 亚洲人午夜精品射精日韩| 精品久久8x国产免费观看| 国产精品午夜福利小视频| 亚洲欧美人成网站在线观看看|