Implement Line Trace through Crosshairs
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "DebugPrint.h"
|
||||
#include "Tangible.h"
|
||||
#include "TangibleManager.h"
|
||||
#include "LookAtDetector.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "AnimQueue.h"
|
||||
#include <string>
|
||||
@@ -84,8 +83,9 @@ void AIntegrationGameModeBase::ResetToInitialState()
|
||||
// Clear the PlayerID
|
||||
PlayerId = 0;
|
||||
|
||||
// Clear the actor selector;
|
||||
LookAtDetector = nullptr;
|
||||
// Clear the look-at state;
|
||||
PreviousLookAt = nullptr;
|
||||
CurrentLookAt = nullptr;
|
||||
|
||||
// Reset the clocks.
|
||||
EngineSeconds = 0.0;
|
||||
@@ -225,7 +225,7 @@ void AIntegrationGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick I
|
||||
UpdateConsoleOutput();
|
||||
UpdateTangibles();
|
||||
UpdatePossessedTangible();
|
||||
if (LookAtDetector != nullptr) LookAtDetector->Update();
|
||||
UpdateLookAt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,40 +330,22 @@ AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromContext(UObject *cont
|
||||
return GetFromWorld(context->GetWorld());
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::SetLookAtDetector(UlxLookAtActorBase *selector) {
|
||||
LookAtDetector = selector;
|
||||
void AIntegrationGameModeBase::UpdateLookAt() {
|
||||
// Rotate the variables.
|
||||
PreviousLookAt = CurrentLookAt;
|
||||
CurrentLookAt = nullptr;
|
||||
|
||||
// Make sure the world is fully configured before we attempt to cast rays.
|
||||
UlxTangible *possessed = TangibleManager->GetPossessedTangible();
|
||||
if (possessed == nullptr) return;
|
||||
APlayerController *pc = GetWorld()->GetFirstPlayerController();
|
||||
if (pc == nullptr) return;
|
||||
APawn *pawn = pc->GetPawn();
|
||||
if (pawn == nullptr) return;
|
||||
if (possessed->GetActor() != pawn) return;
|
||||
APlayerCameraManager *cam = pc->PlayerCameraManager;
|
||||
if (cam == nullptr) return;
|
||||
|
||||
CalculateLookAt(pawn, pc, cam);
|
||||
}
|
||||
|
||||
|
||||
// /** Gets the game mode that owns this component, this will always return null on the client */
|
||||
// template <class T>
|
||||
// T* GetGameMode() const
|
||||
// {
|
||||
// // Note: Intentionally getting the game mode from the world instead of the game state as it can be null during game state initialization
|
||||
// static_assert(TPointerIsConvertibleFromTo<T, AGameModeBase>::Value, "'T' template parameter to GetGameMode must be derived from AGameModeBase");
|
||||
// const UWorld* World = GetWorld();
|
||||
// return World ? World->GetAuthGameMode<T>() : nullptr;
|
||||
// }
|
||||
|
||||
|
||||
// // in GameplayStatics
|
||||
// /** Returns the current GameModeBase or Null if it can't be retrieved, such as on the client */
|
||||
// UFUNCTION(BlueprintPure, Category="Game", meta=(WorldContext="WorldContextObject"))
|
||||
// static ENGINE_API class AGameModeBase* GetGameMode(const UObject* WorldContextObject);
|
||||
|
||||
// // Give the URL a chance to override it
|
||||
// if (AGameModeBase* GameModeBase = GetGameMode<AGameModeBase>())
|
||||
// {
|
||||
// EffectiveBotCount = UGameplayStatics::GetIntOption(GameModeBase->OptionsString, TEXT("NumBots"), EffectiveBotCount);
|
||||
// }
|
||||
|
||||
// // In UWorld
|
||||
// /**
|
||||
// * Returns the current Game Mode instance cast to the template type.
|
||||
// * This can only return a valid pointer on the server and may be null if the cast fails. Will always return null on a client.
|
||||
// */
|
||||
// template< class T >
|
||||
// T* GetAuthGameMode() const
|
||||
// {
|
||||
// return Cast<T>(AuthorityGameMode);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user