Probleme with get/set actor location

hi all,

I have somme probleme with GetActorLocation() and SetActorLocation() function.
I want to make a rester system in my game.

here is my code :
BallBall.h :

protected :

/* teleport to the last save point */
    	void GoSavePointLocation();
    	/* save the reset location */
    	FVector bSavePointLocation;

BallBall.cpp :

/* constructor */
ABallBall::ABallBall(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
 // do stuff

bSavePointLocation = this->GetActorLocation(); // save reset location


void ABallBall::GoSavePointLocation()
	this->SetActorLocation(bSavePointLocation , true ); 

void ABallBall::SetupPlayerInputComponent(class UInputComponent* InputComponent)
	// do stuff 
	InputComponent->BindAction("Reset", IE_Pressed, this, &ABallBall::GoSavePointLocation);

If i presse Reset key this dosent work if the ball is in the floor ( wtf ) but " work " if the ball is in the air. I say " work " cuz the ball dont teleport in the right location saved by constructor .


Edit : i understand now, use

bSavePointLocation = this->GetActorLocation();

in constructor is wrong . i think my bSavePointLocation will be the PlayerStart Location but no its all time (0,0,0). H
How i can get PlayerStart location ?

Could you use the BeginPlay() function for that?
This should be fired when the Player is spawned and the location
should be the PlayerStart. :open_mouth:

.h header file

virtual void BeginPlay() override;

.cpp c++ file

    void ABallBall::BeginPlay()
           bSavePointLocation = this->GetActorLocation();

Nice, this work !
Thanks :slight_smile:

(: Glad to hear that. Would you mind clicking on the check mark of my answer to mark this question as resolved?