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"

Passing components to sub-actors (C++)

I am trying to create a set of C++ classes that provide VR functionality. The structure that I am using is that my player Pawn class owns two sub-actors (i.e. classes derived from AActor) for the left and right MotionControllers.

In the BeginPlay() function of my Pawn I have the following:

 FActorSpawnParameters SpawnParameters;
 SpawnParameters.Owner = this;

 LeftController = GetWorld()->SpawnActor<AMotionControllerActor>(FVector::ZeroVector, FRotator::ZeroRotator, SpawnParameters);

On AMotionControllerActor I have the possibility to set a UStaticMeshComponent*, which is used for the visualization of the MotionController ingame. So in AMotionControllerActor I do the following:

 UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly, meta = (ExposeFunctionCategories = "Mesh,Rendering,Physics,Components|StaticMesh", AllowPrivateAccess = "true"))
 class UStaticMeshComponent* StaticMeshComponent;

If I would use the MotionControllerActor directly, this allows me to set the mesh from the Details pane of the Unreal Editor. Which is what I want.

However, because I spawn the AMotionControllerActor inside my player Pawn class I can no longer access the MotionControllerActor directly (which makes sense). So I would like to expose the UPROPERTY for the left and right MotionController directly from within my Pawn to the MotionControllerActor. In other words: I want to be able to pass through the UStaticMeshComponent for the Left and Right controller directly from the Details pane associated with the player Pawn to the AMotionControllerActor inside the Pawn.

Maybe this is extremely simple, but somehow I have been unable to come up with a good method to accomplish this.

Product Version: UE 4.13
Tags:
more ▼

asked Oct 12 '16 at 06:36 AM in C++ Programming

avatar image

wimk
28 1 2 5

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

1 answer: sort voted first

I did'nt test.

But i will keep the static mesh as UProperty in your Player Pawn And when you span your subActors, you call a "Initiliaze" method wich take a UStaticMeshComponent* or a class

define your initialize function in your "AMotionControllerActor"

then the call should like:

  FActorSpawnParameters SpawnParameters;
  SpawnParameters.Owner = this;
  
  LeftController = GetWorld()->SpawnActor<AMotionControllerActor>(FVector::ZeroVector, FRotator::ZeroRotator, SpawnParameters);
 LeftControler->Initialize(MyStaticMesh);

don't know if it works but you can then create the mesh and attach it to your rootcomponent. Hope it helps

more ▼

answered Oct 12 '16 at 08:49 AM

avatar image

Draykoon
111 4 4 5

avatar image wimk Oct 16 '16 at 10:49 AM

Thanks! That does seem to work. It is not my preferred solution (pass through would be more elegant if it were possible), but this will do for now.

(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