[C++] Inheriting variables from another class WITHOUT Spawning

I’m having a huge issue with not being able to getting my characters Location without Spawning actor :confused: I just want to get the variable without having to spawn it. here’s my code I have

    // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
    #include "SideScrollerConcept.h"
    #include "CorruptBot.h"
    #include "CorruptAI.h"
    #include "SideScrollerConceptCharacter.h"
    ACorruptBot::ACorruptBot(const class FPostConstructInitializeProperties& PCIP)
    	: Super(PCIP)
    	AIControllerClass = CorruptAIClass;
    void ACorruptBot::Tick(float DeltaTime)
    	float Distance;
    	ASideScrollerConceptCharacter *MyCharacter = //HERE IS WHERE I NEED HELP;
        if(MyCharacter != NULL)
    	     Distance = FVector::Dist(this->GetActorLocation(), MyCharacter->GetActorLocation());      
	     if (Distance < 100)
    		     GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Green, TEXT("OH HAI"));

Any Ideas? :frowning:

Thank you soo much!!! Good knowledge for future reference ^_^.

You can get character instance from player controller that possess your character, i assume your game is singl player and you will have only one player controller, then you can do this:

ASideScrollerConceptCharacter *MyCharacter = (ASideScrollerConceptCharacter*)GetWorld()->GetFirstPlayerController()->GetPawn();

If all you need is a location and don’t need functions from that class then you can reduce that to

APawn *MyCharacter = GetWorld()->GetFirstPlayerController()->GetPawn();