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"

How do I set an actor's owner from Blueprint?

I have inventory actors that are supposed to be only relevant to their owner.

In the C++ version of SpawnActor and in previous Unreal Engine versions, there was the possibility to set the spawned actor's owner. However, there seems to be nothing exposed to Blueprints, and there's obviously no setter for an actor's owner.

Is there any way to spawn an actor with a certain owner from Blueprint?

Product Version: Not Selected
Tags:
more ▼

asked Jun 15 '14 at 06:39 PM in Blueprint Scripting

avatar image

pdinklag
123 6 8 12

avatar image Zeustiak Jun 15 '14 at 11:01 PM

Hmm, this would allow me to spawn instances into streaming levels which I can't currently figure out.

Would be a nice feature to have in BP!

avatar image Graftopo Oct 02 '14 at 09:27 AM

Is there an answer on this? I am trying to set the owner of a spawned actor through blueprints but there is no such option. I am using UE 4.4.3 editor.

What i am trying to achieve is in a multiplayer game, to spawn an actor that will be visible only to the playing character and no one else.

avatar image apollyonbob Oct 10 '14 at 08:19 PM

I wish there was a way to bump this question. I asked the same question in the forums before realizing I might look over here. I don't really see how Multiplayer FPS can work in Blueprints without this functionality. Edit: Okay, so commenting does bump. Hopefully some engineer will see it.

avatar image Worrom Nov 26 '14 at 01:33 AM

I'm having a similar issue. I'm adding a weapon to the player, I've tried spawning via "Add ChildActorComponent" and "Spawn Actor from Class". Both didn't set the owner correctly.

In a Blueprint only solution I've been able to hack around this by detecting if the player is remote and manually hiding the weapon in its Blueprint.

In the future either a native function SetOwner or including this functionality in functions that attach actors to a parent would be incredibly useful.

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

3 answers: sort voted first

So what I had to do for this ultimately was create a C++ Wrapper for the Actor component. This is obviously a less-than-ideal solution as it doesn't really help if you need to set the owner of a Pawn or Character (unless you want to redo your own Pawn/Character) but it did get my problem fixed.

For completeness, for anyone who comes by and sees this, from a Project that had zero C++, I simply went to File > Add Code to Project, that brought up a wizard that walks you through creating a class. Pick a base class of Actor, then give the class a name, say, ActorBPWrapper, and then it should generate the basic code project. (Don't mess with the directory. Unless you're planning on doing a lot more C++, I don't think it will come up.)

From there, you'll have two files: ActorBPWrapper.h and ActorBPWrapper.cpp.

Think of the .h file as "What the class does" and the .cpp file as "How the class does it." So you want to put in the .h file (in between the { } (curly braces) but underneath the "GENERATED_UCLASS_BODY()" line):

 public:
     
     UFUNCTION(BlueprintCallable, Category = Actor)
     void SetOwnerTo(AActor* NewOwner);


Then, in the .cpp file, you'll want to put the following at the very bottom of the file (after the last } (curly brace)):

 void AOwnedActor::SetOwnerTo(AActor *NewOwner)
 {
     Super::SetOwner(NewOwner);
 }

That should be pretty much it. I changed the name from "SetOwner" to "SetOwnerTo" because I didn't want to actually try to override (or hide) the existing SetOwner function.

Like I said, it's a less than ideal solution, but it's fast and it works.

I should note that if they put that "UFUNCTION(BlueprintCallable, Category = Actor)" on top of the existing SetOwner function, it would fix this issue. And based on the content of the SetOwner function, I think that could be done without effort. Unfortunately I don't know where to put this request.

more ▼

answered Oct 11 '14 at 07:18 AM

avatar image

apollyonbob
53 2 70 12

avatar image Worrom Nov 26 '14 at 01:42 AM

This ultimately worked for me, though you should change the function void AOwnedActor::SetOwnerTo(AActor *NewOwner) to void AActorBPWrapper::SetOwnerTo(AActor *NewOwner)

avatar image A Space Ostrich May 08 '15 at 10:24 AM

What do you do after this, I can't see any obvious changes now that this is in the project.

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

I'm having the same problem. I spawn a gun with two meshes, but i can only see the 3rd person mesh because i can't set its owner. That's an essential feature. We have to make some noise so they see it and fix it.

more ▼

answered Mar 14 '15 at 07:22 PM

avatar image

CarlosBC
31 1 2 9

avatar image Theololz Mar 15 '15 at 02:12 PM

got the same issue. Please make 'set Owner' callable by blueprints!

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

I had the same problem trying to get the owner of a spawned actor. You can make one yourself by creating a variable in your spawned actor and set it to 'Expose on Spawn' in the details panel. When you use the Spawn actor function there will be an input you can pass the owner into.

more ▼

answered Jun 20 '14 at 07:11 AM

avatar image

Twvlsman
6 1

avatar image pdinklag Jun 20 '14 at 09:25 AM

Well, that's a way to create a simple reference. But it does not solve the problem of not being able to set the Actor's actual owner, which is used internally to determine network relevancy (`bOnlyRelevantToOwner`).

avatar image Hyperloop Oct 04 '14 at 03:11 PM

Did you ever find an answer for this? I am looking for a solution as well.

avatar image pdinklag Oct 05 '14 at 09:45 AM

Nope, no solution yet as far as I know.

(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