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"

Destructible Instanced Static Mesh Components?

I've been able to make a procedurally generated level using instanced static mesh components (simple blocks). Now I'm trying to allow the player to apply damage to these blocks to blow them up. I know how to do this by creating destructible mesh components, but I can't figure out how I can use a Destructible Mesh instead of a Static Mesh for procedural generation. Is there some workaround so that I can allow my player to destroy my procedurally generated world?

Thanks!

Product Version: UE 4.8
Tags:
more ▼

asked Jul 18 '15 at 06:14 PM in Blueprint Scripting

avatar image

akaapplications
56 7 11 20

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

2 answers: sort voted first

The best way to do destruction for InstancedStaticMeshComponents is to detect when an individual instance has been damaged and then delete individual instances and spawn a destructible actor in its place. That's possible to do in 4.8 but it's a bit clunky.

For line traces or point damage, Hit.Item contains the instance index that was hit.

One issue is that in 4.8 radial TakeDamage doesn't work well with InstancedStaticMeshComponents because it doesn't calculate the damage amount for each instance based on the falloff but rather treats the entire component as a single object.

For 4.9 foliage I made a subclass of HierarchicalInstancedStaticMeshComponent which correctly calculates the damage, and also added some blueprint functions to allow you to find and destroy instances more easily, especially for radial damage.

The first 4.9 preview will be out soon, but the changes are in these commits if you want to have a look sooner:

https://github.com/EpicGames/UnrealEngine/commit/7a7e51a88dd1f0ec472b998d010e42d2a5392812 https://github.com/EpicGames/UnrealEngine/commit/8626c0ad9e757375844bb125544fa1eb5dcd573e

  • Jack

more ▼

answered Jul 20 '15 at 03:34 AM

avatar image

JackP_oldaccount
1.3k 37 11 48

avatar image John Alcatraz Aug 03 '15 at 04:39 PM

Hey Jack, great to see some improvements for the HISMC! HISMCs are really awesome. but I'm curious whether you will for 4.9 also fix the flickering which occurs when HISMCs get scaled?

https://www.youtube.com/watch?v=jpW9IZCd39M

They show LOD0 for one frame after being scaled, and it looks really not nice. For me it's like the worst bug UE4 has at the moment. I need to use HISMCs for this because of performance, ISMCs don't have LODs and would decrease my performance extremely with foliage like this and regular Static Meshes would too.

avatar image JackP_oldaccount Aug 04 '15 at 02:47 AM

Hi John,

I'm sorry that I wasn't made aware of this and had not been assigned the ticket (UE-16534). It was assigned to the rendering team and had not been passed on to me; it's actually a foliage issue.

I've just taken it back and I'll see what I can do but there is very little time left before 4.9.

  • Jack

avatar image John Alcatraz Aug 04 '15 at 03:04 AM

Great, thanks so much Jack, you are awesome :)

avatar image JackP_oldaccount Aug 04 '15 at 03:07 AM

Hey John for your usage case you're only interested in changing the scale of the instances, not their position, right? I should be able to easily keep the existing LOD when changing only the scale or rotation.

  • Jack

avatar image John Alcatraz Aug 04 '15 at 03:14 AM

Yes, I do only change scale and in some special cases (tree get's cut) also rotation, but trees usually don't change the location, I don't have ents in my game :) And for ents I would need to use skeletal meshes anyway. I already told you how awesome you are, this bug is annoying me for months now and I already feared it will never be fixed, so awesome that you just look into it now :)

avatar image VSZ Aug 25 '15 at 05:27 PM

Hi Jack, just checking whether you also spotted the second HISM bug in John Alcatraz's bug report thread.

Specifically this bug -

John Alcatraz Jun 23 '15 at 9:12 AM

"In a packaged project the flickering after scaling occurs the same way as in the editor, but there is one more bug: After adding a new instance (or after scaling an existing one) sometimes all instances are flickering for one frame, and I can't say it for sure but it looks as if the whole HISM would be invisible for one frame , really does not look nice."

I have noticed the same thing as well in packaged projects. Like John I'm also relying heavily on the HISM component for scaling (and thank you so much for making this excellent component!!!) and I'd be grateful if Epic could investigate the flickering issue when adding new instances.

I think the other thread also mentioned a repro project was available; in any case this can be reproduced by dynamically adding instances to a HISM component (eg: in a Tick event) and packaging the project for testing.

avatar image JackP_oldaccount Aug 26 '15 at 02:50 AM

Hi VSZ,

The fix was more involved that I was hoping and we missed the 4.9 cutoff, but we do have a solution for the component scaling. We now patch the HISM tree with new bounds for instances that do not move so they retain their previous LOD and there is no LOD flickering at all.

We also now calculate an LOD for newly added instances which is almost always correct, although if it's at a transition location it will change LODs abruptly rather than with a per-pixel crossfade when the tree does finish building, but it is not really noticeable.

These fixes should be submitted in the next day or so; I'll post back here when they're done.

I will investigate the issue with all instances flickering when constantly adding instances in tick only for packaged builds. I think this is a separate problem....

  • Jack

avatar image John Alcatraz Aug 26 '15 at 03:08 AM

Hi Jack, great to hear you have found a solution to the LOD flickering bug! So awesome. Could you add the fix in one of the possible hotfixes for 4.9 or will we definitely have to wait for 4.10 (or build it manually)?

The bug with all instances flickering does not only occur if you constantly add instances, one time adding or scaling an instance can be enough, at least this is what I wrote above and I can't really remember what exactly I did back then :)

Constantly adding instances would need a lot of performance, right? I think once someone from Epic told me that adding or removing instances in a HISMC can be quite expensive, do I remember this correctly? I think adding an instance to a HISMC where already 200 instances are inside is more expensive than adding one instance to a HISMC where only 100 are inside, right?

avatar image JackP_oldaccount Aug 26 '15 at 03:18 AM

I'm afraid this will have to wait for 4.10 or for you guys to build it yourselves. We generally only issue hotfixes for things broken by the release itself - the testing required for any release is huge and is the limiting factor in our release schedule, so adding other items to 4.9.x will push back 4.10.

Constantly adding instances to an HISMC isn't that bad. It will have a background thread building the tree most of the time so there is that CPU hit. Any additional instance requires the whole tree to be rebuilt, so adding an instance to a 200-instance HISMC will take longer than for a 100-instance but the extra work happens in the background.

I'll investigate the issue with all instances flickering. We have not seen that for a long time but I'm looking at the with packaged build case now.

avatar image JackP_oldaccount Aug 26 '15 at 06:56 AM

Hi VSZ,

I haven't been able to reproduce any flickering with a blueprint adding a new instance every frame, in packaged builds or otherwise. I tested 4.9 with and without the LOD fix mentioned in this thread.

If you can reproduce it in 4.9, please post a new AnswerHub thread about it with a sample project and we'll take a look.

Thanks Jack

avatar image John Alcatraz Aug 26 '15 at 04:18 PM

Hi Jack,

why do you always mention "every frame"? I don't think it makes any difference here. I just tested it with my project where I scale instances once a second and after packaging sometimes all the instances (so even the ones which don't get scaled) flicker, and it's a flickering where I think I can see the landscape below for one frame, so they are invisible.

I converted the project to 4.9 now and I get the exact same problem there. Are you sure you have not tested it both times with the fix applied? I should upload the project now?

avatar image John Alcatraz Aug 26 '15 at 04:32 PM

Here is a new answerhub thread about it with a repro project:

https://answers.unrealengine.com/questions/291489/hismc-flickers-in-packaged-project.html

avatar image JackP_oldaccount Aug 27 '15 at 01:36 AM

Hi John,

If you re-read my post, you'll see I wasn't addressing you with my request for a new thread, I was addressing VSZ who posted a new issue reporting flickering when adding instances every frame.

Regarding your repro you just posted, this is the LOD flickering in ticket UE-16534 which incidentally we fixed today. I just confirmed your content before/after the fix and it vastly improves the appearance and there is no LOD flickering.

The fix is available on github here and the two files it concerns, HierarchicalInstancedStaticMesh.cpp and HierarchicalInstancedStaticMeshComponent.h are drop-in replacements for the 4.9 versions.

Cheers Jack

avatar image John Alcatraz Aug 27 '15 at 02:31 AM

The bug VSZ mentioned was posted originally by me, and this is what I uploaded the repro project for. It's not about the LOD flickering (although it also is apparent in the repro project) but about the flickering of the whole HISMC, so even the instances which did not get modified. The whole HISMC seems to be invisible for one frame. Maybe you should re-read VSZ's post :)

He said "this can be reproduced by dynamically adding instances to a HISM component (eg: in a Tick event) and packaging the project for testing", but he never said anything about "adding instances every frame". The tick event was just an example. And it also happens on scaling, not only on adding/removing instances.

avatar image John Alcatraz Aug 27 '15 at 02:32 AM

And thanks a lot for the fix on github :)

avatar image JackP_oldaccount Aug 27 '15 at 03:07 AM

No worries, I understand now. I will reply in the new thread about this.

avatar image Angel Tsvetkov Dec 23 '15 at 06:05 PM

Thank you so mush JackP for the idea to use Destructible mesh only in place of hit. Works perfect in 4.10.1 with respective replaced instance of its InstancedStaticMesh from a lots of in the level. Thanks man!

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

HI Mate

Yes, you can give each block a "Health" Var. When health = 0. Destroy actor / Mesh. Place a DM there and apply damage to it.

But they would need to be a BP. Give it a go, see how you Frame Rate sits.

Here is a quick example of it I did.

https://www.youtube.com/watch?v=1GSOGo_YK64

Narg

more ▼

answered Jul 19 '15 at 09:52 AM

avatar image

Narghile
1.7k 74 38 110

(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