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"

UStaticMeshComponent doesn't show Details Panel

Hi I'm working on a game where I have several different shields that I can use for certain characters. So I CreateDefaultSubobject and attach it to the Rootcomponent. This works all well and inside the game I get my shield however in my Blueprint I get not details panel for it.

What I'm doing is reading a DataAsset in Character constructor and getting the shield that a certain character has and with an if else statement decide which one to create.

If I don't have the if else statement and only one specific Component I can see the Details Panel and play around with it. But with the if else statement if just doesn't show up. I do see a that the Component is Inherited.

Does anyone know why this might occur or if anyone might know a fix to the problem?

Currently Working on a Macbook Pro OSX, UE 4.8.3

alt text

Product Version: UE 4.8
Tags:
more ▼

asked Aug 06 '15 at 09:56 AM in C++ Programming

avatar image

wettrix
101 12 18 25

avatar image Mhousse1247 Aug 06 '15 at 11:05 AM

Are you using this?

 UPROPERTY(Category = MeshComp, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))

If yes , can you post the code where the component is created , this will help to have a clear idea

avatar image wettrix Aug 06 '15 at 01:54 PM

I might have posted a reply but I don't see it in here so I'll do a post again.

Since I'm not at home atm, this is the basic structure of the code.

 .h
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyComponent, meta = (AllowPrivateAccess = "true"))
 class UMyComponent_Shield* ShieldComponent;
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyComponent, meta = (AllowPrivateAccess = "true"))
 class UMyComponent_Deflect* DeflectComponent;
 
 
 .cpp
 AMyRobotCharacter::AMyRobotCharacter()
 {
     FString GetComponentName = GetDataAsset_Things_WithStaticLoadObject.TSubclassOf < UMyComponent >;
 
     // Set Movement
     // Set Camera
     // etc
 
     if (GetComponentName.Contains(TEXT("Shield"))
     {
         ShieldComponent = CreateDefaultSubobject<UMyComponent_Shield>(TEXT("Shield Component"));
         ShieldComponent->AttachTo(RootComponent);
     }
     else if (GetComponentName.Contains(TEXT("Deflect"))
     {
         DeflectComponent = CreateDefaultSubobject<UMyComponent_Deflect>(TEXT("Deflect Component"));
         DeflectComponent->AttachTo(RootComponent);
     }
 }

If you only use one of either Shield or Deflect component it works and you can see the Details Panel. But if you do this if else statement it doesn't display the contents. If I put both of them in the editor crashes so I can't have 2 UStaticMeshComponent and then remove one from the game after Initialization.

Currently I have Data Assets for my Characters setup & stats, so I set in there what component I want my specific Character to use, since I want to have different Robots with different abilities.

I hope this gives a better idea.

avatar image mfish Aug 07 '15 at 01:04 PM

Instead of having two UStaticMeshComponents that you're swapping out I'd suggest using a single UStaticMeshComponents and two UStaticMesh variables that you switch between. Something like this:

 .h
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyComponent, meta = (AllowPrivateAccess = "true"))
 class UStaticMeshComponent* HoldingComponent;
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyComponent, meta = (AllowPrivateAccess = "true"))
 class UStaticMesh* ShieldMesh;
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyComponent, meta = (AllowPrivateAccess = "true"))
 class UStaticMesh* DeflectMesh;

 .cpp
 AMyRobotCharacter::AMyRobotCharacter()
  {
      FString GetComponentName = GetDataAsset_Things_WithStaticLoadObject.TSubclassOf < UMyComponent >;
  
      // Set Movement
      // Set Camera
      // etc
 
      HoldingComponent = NewObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass());
      HoldingComponent->AttachTo(RootComponent);
      if (GetComponentName.Contains(TEXT("Shield"))
      {
          HoldingComponent->SetStaticMesh(ShieldMesh);
      }
      else if (GetComponentName.Contains(TEXT("Deflect"))
      {
          HoldingComponent->SetStaticMesh(DeflectMesh);
      }
  }

avatar image wettrix Aug 09 '15 at 02:29 AM

Yea that's not a bad idea. Never though of it like that. I'll give it a try. Thank you mfish.

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

0 answers: sort voted first
Be the first one to answer this question
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