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. 

How can I grab a particular component off of a root component?

I am trying to grab the Static Mesh Component off of my root Component, which I am doing right now by using GetChildernComponents which returns all Children. Then I go through all of the components looking for there name to match up, EX: SM is the StaticMesh Component. I However would like to look for them by there type and not by a name. I tried IsA(), but I could never find the right parameters for it to Run. So my question is, if I have an array of all Child components how do I check the type of them so that I can use an if/switch statement to stop at the Component that is the StaticMesh, Or the Collider,ETC. Also is there a way to query the RootComponent for a particular Component by type.

Product Version: Not Selected
Tags:
more ▼

asked May 05 '14 at 12:37 AM in C++ Programming

avatar image

TuckerBMorgan
6 2 3 2

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

1 answer: sort voted first

hi, you didn't say what your root class is, but assuming it is ACharacter you could maybe use these methods ?

     virtual UActorComponent* FindComponentByClass(const UClass* Class) const OVERRIDE;
 
     template<class T>
     T* FindComponentByClass() const
     {
         return AActor::FindComponentByClass<T>();
     }

they are both defined in ACharacter.h and if they aren't what you need maybe you can take a look what those methods do and implement a variation of them. Hope that helps :)

Chrys

more ▼

answered May 05 '14 at 02:49 AM

avatar image

Chrys
301 21 27 44

avatar image TuckerBMorgan May 05 '14 at 03:31 AM

This is what I need, however I seem to be unable to get it right, but would the Parameter for the function be, it says that OtherActor->FindComponentByClass(UStaticMeshComponent); is invalid, the error being Type name is not allowed.

avatar image enlight_2014 May 11 '14 at 06:04 AM

You're getting that error because you're not passing in the right type of argument, this is what you should be doing: OtherActor->FindComponentByClass(UStaticMeshComponent::StaticClass())

(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