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. 

variable for actor palced in world

I have an an Aim class which inherit form Actor class. I placed this actor in the world and i whish to have acces to it in my c++ code. So i wanna create a variable where may i drag and drop it from world.

Not working:

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mesh)
             AActor* Aim;

I can choose object in editor but it's not assigning it and just makeing a none value

   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mesh)
             Aim* Aim;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mesh)
             AActor<Class Aim>* Aim;

Code is not compiling.

Product Version: Not Selected
Tags:
more ▼

asked Aug 27 '14 at 04:19 AM in C++ Programming

avatar image

Virusik
68 12 16 17

avatar image Duncan Dam Aug 27 '14 at 06:14 AM

Your question kind of confused, not sure what you want to do here. Can you explain more clearly ? Like i don't understand about create a variable and drop in the world, you can only create a blueprint then you can drop in the world, and blueprint is a class not a variable.

avatar image Virusik Aug 27 '14 at 06:29 AM

Yea i forgotten to add that i wanna have acces from other class. So from other class i am making variable to storage the object of other class which is placed in a world. And i whish to be able to drag and drop an object FROM a scene to that variable.

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

1 answer: sort voted first

Oh, so blueprint from Aim class is a class, what you want to set is an instance of Aim class, do this

 UPROPERTY(EditDefaultsOnly, Category = Mesh)
 TSubclassOf<class Aim> AimClass

this will let u set a blueprint of aim class, and to use u need to spawn this class and set to Aim variable

 Aim* AimActor = GetWorld()->SpawnActor<Aim>(AimClass);








more ▼

answered Aug 27 '14 at 06:44 AM

avatar image

Duncan Dam
3.1k 121 50 164

avatar image Virusik Aug 27 '14 at 07:35 AM

Yeap it worked thank you. But still its spawning an actor via script, is it possible to having a variable which stores reference to instance of a Aim class ? (Yep it is but u have to search in getworld(), i wish to drag and drop :P?)

avatar image Duncan Dam Aug 27 '14 at 07:47 AM

Aim* AimActor is reference to instance of Aim class, the only way you can drop instance to this is that instance already in Level.

avatar image MadScorp Aug 27 '14 at 01:06 PM

If you wrote something like that:

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ship")
 AActor * SomeActor;
 

Then in editor you will see Field "SomeActor" in which you can "place" any object that was driven from AActor. But you must understand that you can`t place there an object from content browser. Because all you can see in content browser did not exist in level, it is only Classes. But if you place something from content browser to you level, unreal will construct an object for you class (in most cases it will be driven from Actor). Then you can select you Actor (that already exists in level) in field "SomeActor"

(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