x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 .

Thanks

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 ?

Product Version: Not Selected
Tags:
more ▼

asked Aug 31 '14 at 09:56 AM in C++ Programming

avatar image

mamax49
20 7 9 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

 .h header file
 
 
 virtual void BeginPlay() override;
     
 
 .cpp c++ file
 
 
     void ABallBall::BeginPlay()
     {
            Super::BeginPlay();
     
            bSavePointLocation = this->GetActorLocation();
     }

more ▼

answered Aug 31 '14 at 04:57 PM

avatar image

eXi
6.8k 333 185 470

avatar image mamax49 Aug 31 '14 at 05:49 PM

Nice, this work ! Thanks :)

avatar image eXi Aug 31 '14 at 05:56 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question