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"

How can I get the actor location from an actor in another class?

I want to make a system where my character would teleport to another actor's location. So far, almost all of my attempts have involved this

 LedgeRLocation = &ALedgeR::GetActorLocation();

However, it always has the same error: "a nonstatic member reference must be relative to a specific object". I doubt this has anything to do with the way I'm trying to teleport the character because I get the same error no matter where I use it within the character class. Can someone let me know how to do this properly?

Product Version: UE 4.18
more ▼

asked Jun 04 '18 at 06:25 AM in C++ Programming

avatar image

11 3 5 10

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

1 answer: sort voted first

ALedgeR is not a spawned actor in the scene but a class type

 ALedgeR* MyLedgeActor = World->Spawn....
 FVector Location = MyLedgeActor->GetActorLocation()

more ▼

answered Jun 04 '18 at 10:20 AM

avatar image

Ali Akbar
691 2 6 8

avatar image Apokalypto_ Jun 08 '18 at 02:53 AM

I tried to access the location variable in my character class, but I got the same error.

Also, is there a way to make it so that the character gets the location of the nearest LedgeR actor? I know that this isn't part of the initial question, but as my game grows and I add more LedgeRs in more levels, I'm afraid that this method would get tedious and/or unorganized.

(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