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"

How to enable section-based collision on an actor base

I'm trying to enable collision (for visibility through ray-trace purposes) on single mesh sections by checking for the material that they have applied: if it is a translucent one, collision is disabled, otherwise it is enabled. That is quite easy to do by changing the flags in the referenced mesh:

 TArray<UMaterialInterface *> mats = actor->GetStaticMeshComponent()->GetMaterials();
 for (int m = 0; m < mats.Num(); m++)
 {
    if (mats[m]->GetBlendMode() == BLEND_Translucent)
    {
       FMeshSectionInfo info = actor->GetStaticMeshComponent()->GetStaticMesh()->SectionInfoMap.Get(0, m);
       info.bEnableCollision = false;
       UStaticMesh * mesh = actor->GetStaticMeshComponent()->GetStaticMesh();
       mesh->SectionInfoMap.Set(0, m, info);
       actor->GetStaticMeshComponent()->SetStaticMesh(mesh);
    }
 }

 //same way but info.bEnableCollision = true for opaque etc.
 

This way all instances of such a mesh get changed though, even if they are using different materials which should mean not all of them have to get the same collision configuration (namely, this way the last analyzed rules all their effective collision configuration).

Is there a way to disable/enable collision on single sections for single actors rather than to all those sharing the same mesh? Although in the Learning/Marketplace scene I never identified same mesh objects having different materials applied, it does seem pretty useful to do that so I'd like to resolve the problem right now.

Product Version: UE 4.17
Tags:
more ▼

asked Sep 25 '17 at 04:19 PM in C++ Programming

avatar image

Boozee
11 2 4 4

(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