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"

Get the pointer to a player in the gamemode class

I'm trying to access the custom character that I dragged and dropped into the level. How exactly can I get a pointer to that? Also as a bonus question, when I remove my character from the level and just assign the DefaultPawnClass to the character I wanted, the camera acts the ways it should but the character is invisible. I dragged and dropped a playerstart into the level and just pressed start. I have the code accessible if needed.

Product Version: UE 4.21
Tags:
more ▼

asked Feb 09 '19 at 12:41 AM in C++ Programming

avatar image

Jams Charles
8 1 1

avatar image Jams Charles Feb 09 '19 at 05:54 PM

Bump. Still haven't found the answer.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I guess this gonnan be helpful for you, majority of nodes you see in Blueprints are direct buindings of C++ class, some of htem are specially made for blueprint use and they are gethered in UBlueprintFunctionLibrary based classes, one you probably will most useful is UGameplayStatics

http://api.unrealengine.com/INT/API/Runtime/Engine/Kismet/UGameplayStatics/

Even thru they made for blueprint, you can still use them in C++, it will be probably help transition. And don't worry if you call those via C++ they are not bound to blueprint lower perfromance, but some functions are not optimized like for example GetAllActorsOfClass, in C++ insted you can use TActorIterator which allows you to break the search loop if you find actors you looking for and save up CPU time, while that function will loop to the end to create resulting array.

There one that you look for:

http://api.unrealengine.com/INT/API/Runtime/Engine/Kismet/UGameplayStatics/GetPlayerPawn/index.html

WorldContextObject is object in perticilae world, so all you need to is deliver any actor pointer to it, if you already in actor just use this.

But normaly in C++ you should get playerconteroller and from that possessed pawn and in single player form actor you can do this GetWorld()->GetFirstPlayerController()->GetPawn()

more ▼

answered Feb 10 '19 at 03:31 AM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image Jams Charles Feb 10 '19 at 01:01 PM

Based on what ive seen on the internet i have been casting GetWorld()->GetFirstPlayerController()->GetPawn() into my own character. Is this correct?

(comments are locked)
10|2000 characters needed characters left
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