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"

Instanced static mesh does not trigger collisions

Hi,

I've made a simple level generator using Instanced Mesh Components. Everything was working great, but I've decided to split the map into smaller chunks. I moved the required components to a new Actor class and spawn a grid of chunks and instantiate meshes in them. After that, the collisions stopped working and the character just drops through it into the abyss. What could be the issue here? The physics and collision settings on the components are exactly the same. All that's different is that instances are added to actors spawning at runtime instead of one being there from the start. Does that make any difference?

Here's the chunk's constructor

 AMapChunk::AMapChunk()
 { 
 StaticMeshComponent = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("FloorMesh"));
 StaticMeshComponent->RegisterComponent();
 StaticMeshComponent->ReleasePerInstanceRenderData();
 StaticMeshComponent->InitPerInstanceRenderData(true);
 StaticMeshComponent->SetFlags(RF_Transactional);
 AddInstanceComponent(StaticMeshComponent);
 
 RootComponent = StaticMeshComponent;
 }

Any ideas? Does the component need the collisions to be initialized manually since it's spawned and used during beginplay?


UPDATE:

Oddly enough, after switching transform's mobility in editor DURING runtime the collisions seem to work again. I'm going to look into that...

Product Version: UE 4.20
Tags:
more ▼

asked Aug 12 '18 at 01:07 PM in C++ Programming

avatar image

The Majestic Bob
1 1 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

So I have found a workaround for the issue. Like i mentioned in the update changing component transform's mobility fixes the issue. What I do is set the mobility on BeginPlay and change the default one in the blueprint to something else, so it gets updated on runtime, which makes it work, but I'm sure there has to be a way to do it properly.

more ▼

answered Aug 15 '18 at 04:50 PM

avatar image

The Majestic Bob
1 1 2

(comments are locked)
10|2000 characters needed characters left

Here is my setup:

     StaticMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
     StaticMeshComponent->SetNotifyRigidBodyCollision(true);
     StaticMeshComponent->SetSimulatePhysics(true);
 
     // This part is optional
     StaticMeshComponent->SetLinearDamping(.3f);
     StaticMeshComponent->SetAngularDamping(.3f);

more ▼

answered Aug 13 '18 at 01:00 PM

avatar image

Aericks
95 6 8 17

avatar image The Majestic Bob Aug 15 '18 at 04:23 PM

Hi,

I have tried your solution, but the issue still remains. If I place a chunk on the map in editor it works properly, but not when it's spawned during runtime. I wonder if there is a method that doesn't get called because of that...

(comments are locked)
10|2000 characters needed characters left
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