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"

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 a reference of a Mesh from Editor to C++ Code

Hi guys, I am new and am going though the video tutorials. In the LevelCreation tutorials there is a blueprint that implements an Auto-sliding Door with a box trigger. I was wondering how can I do that with C++ code only. I am comming from Unity and I was wondering, how I can get the reference of the door from the editor and give it to the C++ code directly (By drag and dropping - just like in Unity). This is a feature that I like very much in Unity and I was wondering if it is possible in Unreal. If it is not, can you tell me how I can get a reference to the door?

Product Version: Not Selected
Tags:
more ▼

asked Jun 23 '14 at 08:28 PM in C++ Programming

avatar image

dbrizov
329 21 22 43

avatar image Shadowriver Jun 23 '14 at 11:43 PM

What exacly you mean by the door? Blueprint or Mesh etc.

avatar image dbrizov Jun 24 '14 at 07:31 AM

The door is a static mesh. I want to take a reference of the door in the C++. I am actually confused a little. The door is a static mesh or and actor with a static mesh component? I just want to take a reference of the door that is currently in the Scene.

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

2 answers: sort voted first

ActorIterator

you're better off giving your Door Actor a specific name via the F4 menu and then looking it up in C++ using the ActorIterator

in an AActor extending class

 AStaticMeshActor* AMyActorExtendingClass::GetMyDoor()
 {
   for(TActorIterator<AStaticMeshActor> Itr(GetWorld()); Itr; ++Itr)
   {
    if(Itr->GetName() == YourDoorName)
    {
     return *Itr;
    }
  }
 }

Enjoy!

Rama

more ▼

answered Jun 24 '14 at 02:12 PM

avatar image

Rama
10.6k 446 343 1086

avatar image dbrizov Jun 24 '14 at 05:13 PM

This works. Thanks very much mate. Unfortunately now there is performance issue. I mean, I have a lot of static meshes in the scene. Is there a faster way to do it?

avatar image dbrizov Jun 24 '14 at 07:17 PM

Actually I found a way. I Simply made an AStaticMeshActor* property with EditAnywhere flag. Now it is visible in the Editor and I Drag and Dropped the static mesh into the property.

avatar image NoobsDeSroobs Jan 16 '15 at 04:19 PM

I am trying to do something similar. I have two BPs with a mesh as one component and I want to set the my TSubclassOf<class AActor> WhatToSpawn; variable according to the variables set during runtime.

The goal is to simply be able to spawn different actors based on how many, the sizes, maps, what instantiated the spawning etc. Any tips?

I was hoping we could reference something by name or relative path, but I couldn't find anything.

Thanks in advance.

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

If you already have the object in the level, you have to interact between the actors. If you want to spawn and manage it from code, do something like this in the constructor:

 //Declaration in .h file
 UPROPERTY()
 class UTexture2D* BarFillTexture;
 
 //in .cpp constructor
 static ConstructorHelpers::FObjectFinder<UTexture2D> BarFillObj(TEXT("/Game/UI/HUD/BarFill"));
 BarFillTexture = BarFillObj.Object;

This applies to Textures (as in the example) as well as Meshes and other stuffs.

more ▼

answered Jan 17 '15 at 04:24 PM

avatar image

zamy
391 17 12 32

(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