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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Get Player Location with c++

I need to get the location of the first person camera from a different file in c++. I want to make an actor walk towards the player, but I don't know how to get the player location. Any help is appreciated, thanks.

Product Version: Not Selected
more ▼

asked Mar 22 '15 at 08:03 PM in C++ Programming

avatar image

33 3 4 8

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

2 answers: sort voted first

Here's one way to do it

 ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
more ▼

answered Mar 22 '15 at 08:11 PM

avatar image

710 27 12 40

avatar image fabtasticwill Mar 22 '15 at 10:46 PM

That worked perfectly. Thank You!

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

I know this is a two years old question but, since you can still find it when googling, I'd like to point out you can also use:


Which I personally find easier to grasp.

more ▼

answered Mar 02 '17 at 06:27 AM

avatar image

Telmo Valverde
16 1 5

avatar image HeavenlyGamesBoss Apr 14 '17 at 07:40 AM

Hi Telmo, I actually thought this thread was useful. I have been trying to use the above line in my C++ code in Unreal. I don't have any issues with creating a line like the first line but as soon as I try to use GetName(), my editor crashes as I press play and it runs the GetName() or GetActorLocation() line.

avatar image Harry2 Feb 07 '18 at 01:15 PM

Thanks for posting this. I have to sometimes run the below code to get it to work for me.

(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