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"

USceneComponent With C++

Hi, i'm just wondering how you can give a class a transform. I know i can use blueprint to give the object a transform with the scene component but i would like to be able to add a root component in C++ that can give the class a transform. I have been looking around and found the USceneComponent but i'm having trouble getting one into my code, anyone have an example for me to try?

// Thanks

Product Version: Not Selected
more ▼

asked Apr 08 '14 at 01:44 PM in C++ Programming

avatar image

200 54 54 64

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

1 answer: sort voted first

The AActor class has a RootComponent property. If you look at a class such as AAmbientSound you can see how a SceneComponent subclass is instantiated and then assigned to the RootComponent pointer. This gives your AActor its position in the world.

more ▼

answered Apr 08 '14 at 01:48 PM

avatar image

Marc Audy STAFF
2.2k 42 35 95

avatar image Solicio Apr 08 '14 at 02:15 PM

Alright i'll have a look at that, thanks for the help.

avatar image Solicio Apr 08 '14 at 02:17 PM

Although, do i need to have one of the subclasses? I cannot just have the parent class in order to get a position in the world?

avatar image Marc Audy STAFF Apr 08 '14 at 02:20 PM

You can use the SceneComponent directly. As it says in its header: " A SceneComponent has a transform and supports attachment, but has no rendering or collision capabilities. Useful as a 'dummy' component in the hierarchy to offset others."

I did a quick look and an even more relevant example to your case is in AMatineeActor. Here are the relevant lines:

 TSubobjectPtr<USceneComponent> SceneComponent = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneComp"));
 RootComponent = SceneComponent;
avatar image Solicio Apr 08 '14 at 02:34 PM

Alright, thanks a lot! Really helped :)

(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