1 在AuraPlayerController.h中

增加

public:

  virtual void PlayerTick(float DeltaTime) override;

private: 

  CursorTrace();


2 在AuraPlayerController.cpp中实现   PlayerTick,CursorTrace

PlayerTick()

{

  CursorTrace();

}

CursorTrace()

{

  FHitResult CursorHit;

  GetHitResultUnderCursor(ECC_Visibility,false ,CursorHit);

  if(!CursorHit.bBlockingHit) return;

 

  LastActor = ThisActor;

  ThisActor = Cast<IEnemyInterface>(CursorHit.GetActor());

 

  if(LastActor == nullptr)

  {

    if(ThisActor!=nullptr)

    {

      ThisActor->HighlightActor();

    }

    else

    {

      

    }

  }

  else

  {

    if(ThisActor == nullptr)

    {

      LastActor->UnHighlightActor();

    }

    else

    {

      if(LastActor != ThisActor)

      {

        LastActor->UnHighlightActor();

        ThisActor->HighlightActor();

      }

      else

      {

        

      }

    }

  }

}

 

3 在AuraPlayerController.h中

privat:

  IEnemyInterface* LastActor;

  IEnemyInterface* ThisActor;

 

4 在AAuraEnemy.h中

public:

  bool bHighlighted = false;

5 在 AAuraEnemy.cpp中

在HighlightActor()中bHighlighted =true;

在UnHighlightActor()中bHighlighted =false;

posted on 2025-08-11 22:51  偷懒的阿贤  阅读(5)  评论(0)    收藏  举报