A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
New Unity Live Help updates. Check them out here!
Discussion in 'Assets and Asset Store' started by Mir-vadim, May 8, 2019.
I bought RayFire and am trying to figure out the optimization:
I created a sphere with a size of 4 in the new scene, deleted the collider, added the RayFireRigid component, added RayFireMan to the scene.
At the moment of destruction, the profiler shows a 53 ms delay at the RayFireRigid.OnCollisionEnter () event.
I did not change any settings, the sphere breaks into a small number of pieces.
Unity version 2019.1.3
I can’t find it in the documentation or in the video tutorials, how can I increase the optimization (since 53 ms is too much)?
1. You can decrease amount of fragments in Demolition properties.
2. You can set Demolition type to Precache or Prefragment, in this case amount of fragments could be higher.
Check out this overview:
And also keep in mind that Sphere has more than 750 tris, this could be too much for high amount fragments for Runtime demolition. Takes 60ms on my pc.
I use pre-calculated fragments (prefabs) for my game. However, when the object is already destroyed, I want to give the player the opportunity to destroy them into smaller parts. And in this case, to calculate in advance is a bad idea, because there are too many unique fragments.
I tried to destroy the already destroyed piece of the column (60 triangles) - it took 24 ms.
Before that, I used another tool with a much higher performance, which imposed great restrictions (first of all, only 1 material), so I wanted to use RayFire instead.
Is this tool multithreaded? Perhaps it is possible to perform calculations over several frames so that the user does not notice lags? Wait 2-3 frames before the destruction is not as critical and noticeable as large enough lags during the game.
Well, it seems that I did not correctly understand the essence of Precached work. This seems to be doing just that. It is not clear how this will behave with a large number of newly created objects. I will conduct some tests and look at the tutorials again and write again.
As I understood from tests and tutorials, Prefragmented (Precache) does about the same (in terms of optimization) as Runtime, but does it in Awake. That is, the optimization problem remains, but it is transferred to the first frame.
However, this does not solve the problem in the case when the object does not exist at the start of the game. That is, it is either created during the game, or it is a fragment that must then be destroyed again.
That is, when I create (for example, in editor during pause) a RayfireRigid component with demolitionType = Prefragmented (Precache), the same problems appear in the profiler as during Runtime (10-15 ms on cube).
I missed something, and it needs to be done differently?
If not, then the same question: is it possible, at least Prefragmented (Precache), to calculate not for 1 frame, but for several?
This optimization among first features in my TODO list. We wanted to add it in release, but at some point I just had to stop add new features and release what was already done and worked. For now, unfortunatelly, it can not spread fragmentation over few frames. And when we will add such feature it will work for all types, not only for Runtime. I guess now this major will go to the first place to be added next.
Also, if you create in editor during pause a RayfireRigid component with demolitionType = Prefragmented (Precache), then you should also manually click on Precache/Prefragment button as well, to create all meshes/fragments. Because just changing demolitionType manually will not make it precache anything because default demolitionType property when Rigid component was created was Runtime. If you want to add Rigid component in play mode for now you need to deactivate object, add Rigid component, change it's properties and then activate object so Rigid will do all stuff it does in Awake and Start using properties you just set.
As for multi-threading, to save some time I will use my comment from Youtube. We added it at first, but it was not much faster with multi-threading (in some cases even a bit slower), but made everything much more complicated and unstable. It was useful when we fragmented object into hundreds of fragments, but fragmenting in runtime to hundreds of fragments takes too much time, more than 100 ms, so we removed multi-threading support, because in editor such speed increase irrelevant.
EDITED: Well, technically it uses multi-threading, but deep inside mesh slice and cap ops. I ment we tried to spread every fragment generation over threads, and this was not usefull too much.
Is there a very approximate time frame when this version will be released (week / month / half a year) so that I can plan my project (unfortunately, 10ms per simple fragment for my project is very much)?
For now I can tell that it definitely will not take a week and half a year. I myself work on everything Unity related and another guy handle everything library related, I need to talk with him first before share approximate time it will take. I will reply to you in a couple of days.
Rayfire has saved me so much time in the past two weeks it's insane. But I'm also getting a lot of "bad input mesh" warnings like this:
Bad input mesh: Toilet
RayFire.RFFragment:SetFragmentCommon(Int32, MeshFilter, RFSurface, Boolean, Int32) (at Assets/RayFire/Script/Class/RFFragment.cs:241)
RayFire.RFFragment:CacheMeshes(Mesh&, Vector3&, RayfireShatter, RFSurface) (at Assets/RayFire/Script/Class/RFFragment.cs:31)
RayFire.RayfireShatter:Fragment() (at Assets/RayFire/Script/RayfireShatter.cs:106)
RayfireShatterEditor:OnInspectorGUI() (at Assets/RayFire/Script/Editor/RayfireShatterEditor.cs:90)
UnityEngine.GUIUtilityrocessEvent(Int32, IntPtr)As a Playmaker-abusing non-coder I'm just wondering what makes a "good" input mesh. Thanks a million! You're a genius.
Hi, I will reply to you with more info tomorrow, for now I am workin on update with few new properties in Shatter which will significantly decrease amount of such warnings and will make it less sensitive to mesh quality.
Is it possible with this to dynamically crack a building but keep it intact until let say it reaches a 0 health state?
Also does this work with baked lightmaps? I think the inactive mesh is what I was looking for as far as cracks go.
Also I see an option for decals does that include bullet holes and how does that work with the chunking system? And are the smaller pebbles a particle effect oor is that being dynamically made as well in the gun example? Sorry for all the questions I've been fascinated by this asset and my brain is racking.
Bad mesh means that object has open edges / unwelded vertices / negative volume / interpenetrated surface / double faces. And there is a high chance that attempt to fragment it will provide fragments with the same artifacts.
Our shattering engine has algorithms which try to fix all those problems and in build 1.03 they were always On. But it was developed to fix basic problems, like when artist forgot to weld some vertices or some open edge is not capped which means that object has no closed volume. When such object sliced it should cap sliced border and if there are other open edges it will cap them in wrong way. Every fragment usually should perform 10-30 such slices, so at the end you may end up with pretty ugly fragment.
But game objects may have a lot of open edges to save some poly, so our "fixing" made them even worse and this is why you got bad mesh warnings so much. I added "Repair" checkbox in Shatter component in latest build 1.04 which is already available. It is On by default like in previous build, but now you can turn it Off if you get bad mesh warning and try to fragment object without all these fixing operations. But you should know that results could be also bad if input mesh has problems I mentioned.
For last several years we used to work with VFX artists who used it in movies and CGI, so, bad output fragments was not an option for us and for them, I mean having even one tiny artifact on final render could force artist to redo everything he done. Game developers are not so sensitive to final quality, so in some case you can turn Off repair property and try to frag object without fixing ops.
Not like we are ok with this, for some time, while we are fixing bugs you can use this way to fragment your objects which can't be fragmented otherwise. But later we will try to impove these fixing operations so they will be more game geometry friendly.
Runtime fragmentation is suitable for simple low poly objects, up to 400 polys.
If you want to demolish build you should use Connected Cluster object type. In this way it will be demolished at impact or damage points and not connected anymore parts will be simulated as separate clusters.
This feature for now implemented for dynamic objects and I need to spen some time to make it work well with static objects, so user will be able to define cluster area which stay on the ground, so any part which is not connected anymore to this part will fall down. Such support will be added a bit later, for now we are concentrated on fixing bugs.
This Gun video you saw was created with beta version of this component. In released build there is no support for Decals, it will be added later when it will be properly implemented. As for creating holes, it is not actually holes. When you shoout object you can demolish it in Runtime and convert into a bunch of fragments. If this object is Inactive all fragments also will be Inactive and shooting to some fragment you can activate it so it will fall down and it will looks like you just created a hole. ALso you can start with a bunch of Inactive fragments and activate some of them by shooting. But it doesn't create hole in solid object.
I can send you a package so you will be able to try it and decide if this is what you need. let me know if you want to try.
And sorry, but I didn't test it with baked lightmaps. Always used dynamic lighting.
So far it seems the plugin requires .NET 4.0 + C# 7.0 to be correctly compiled. The project I'm working on is targeting .NET 3.5 and C# 4.0. While I could edit the C# scripts to fix the incompatible syntax, I wasn't able to edit the RayFire.DotNet .dll file. Thus the plugin becomes unusable. It would be a pain in the ass if I have to update the assembly and language settings for my 2-year-old project, so is it possible if you can provide a version that is compatible with earlier assemblies?
Yes, it is mentioned in requirements section. I don't think it will be hard to make it work with .NET 3.5, we planned to do this later. I will provide some more info about this tomorrow.
Hi, sorry for delay, we were busy with one nasty bug which was just fixed.
On monday we will try to add .NET 3.5 support.
Appreciated! Heads-up for your update
Hi. we made it work with managed plugin, now I am working on fixing code on C# scripts. Tomorrow or later today I will send you link to new build with .NET 3.5 support.
Was about to start doing some R&D for destruction for my new project today and just found out that this was released.
Have used RayFire for 3dsmax since it first came out ( how long ago was that?)
Looking forward to try this out.
I have question about the fracture feature; Is it possible to fracture objects into hollow objects?
Without the need for the original object to be hollow. I find this feature missing for a lot of fracture system.
That was too long ago
Well, for now ther is no such feature, but I know that some users need it and we will add it later, but not soon, still need to do a lot of other stuff.
Great plugin , Will there be a support for multi material objects?
Cause right now its copy the materials but the fragments are only uses the first material
This is what we are working on right now. It can apply second material for inner faces, but if object has more than 2 materials then it doesn't work as it should. Main problem is that if you have object with several materials/submeshes one of it's fragments may have only few of these materials, so we can't just add another material or keep original material list, we need to create material list for every fragment by it's own submeshes and they can be different for every fragment. This should take a week or so, hopefully.
Build 1.05 released and here is changelog:
Common. DotNET 3.5 support.
Shatter. Multi-material object fragmentation.
Shatter. SkinnedMesh fragmentation support.
Manager. Material Presets. Customizable material density, solidity, friction and bounciness.
Rigid. Destructible state check. Demolish only objects with Destructible material.
Rigid. Tooltips for properties.
Hi, just want to let you know that this feature is almost finished and will be available in build 1.06 in 1-2 weeks.
Hi, this is great news, I look forward to it.
Hi, does this work in the Mac Editor or Windows Only? thanks
It was working during beta test, but we added a lot of stuff since then and I didn't test it yet. I can send you package to test it if you want.
So, I already added ability to spread runtime demolition over defined amount of frames and it works great, finally it is possible to increase amount of fragments or use objects with higher amount of triangles.
Now I am going to add the same support for Precached mode and manual Caching initiation, so it will be possible to start fragment objects some time before it should be demolished, in this way it will start create by several fragments every frame and at demolition moment all fragments will be ready.
This feature perfectly fills gap between Runtime and Precached demolition types.
Build 1.06 released and here is changelog:
- Combine. New Rayfire Combine component. Combines meshes into single mesh. Supports Multi-Material and SkinnedMesh objects.
- Rigid. Runtime caching. Allows to cache fragment's meshes over multiple frames to prevent FPS drop in case of high amount of fragments or hipoly mesh.
- Rigid. New SkinnedMesh Object type. Support for runtime demolition and slicing of SkinnedMesh objects.
- Rigid. Removed Exclude Object type.
- Rigid. Demolition type Precached was renamed to Awake Precache. Precache fragment's meshes in awake.
- Rigid. New Demolition type Manual Precache. Allows to demolish objects to manually precached fragments.
- Rigid. Demolition type Prefragmented was renamed to Awake Prefragment. Prefragment object in awake.
- Rigid. New Demolition type Manual Prefragment. Allows to demolish objects to manually prefragmented objects.
- Rigid. Helpful console messages. Will notify if you have wrong setup.
- Manager. Drag and Angular Drag properties in Material Preset.
- Fixed bug. Fragmentation of objects with normal map.
- Fixed bug. Fragmentation of objects with several materials and negative scale.
- Fixed bug. Manual Prefragment creates Manager (if it is not created) and setup physics accordingly to Material Presets.
- Fixed bug. Manager / Advanced demolition properties / Shadow Casting size threshold property now work correctly.
And here is Runtime Caching feature in action:
Hi, firstly, thanks for adding this feature.
I create a simple build with a stone from the new demo scene, and was able to test on different computers.
In the editor, the profiler shows the delay:
3-7 ms per frame during setup: 20 fragments, 1 piece per frame;
5-8 ms per frame during setup: 20 fragments, 2 pieces per frame;
7-12 ms per frame during setup: 20 fragments, 4 pieces per frame.
Also, everywhere there are peaks + 2-4 ms around the middle or end of the process.
However, in the build, it seems that the delay is much less (2 times) than in the editor. So, on the average device (core i3), rare FPS subsidence begins on several stones of 20 fragments, 1 piece per frame. And very frequent subsidence while simultaneously fragmentation 2-4 stones of 50 fragments, 2 pieces per frame.
Of course, dividing the entire fragmentation process into several frames greatly increases the optimization, however, if this is not performed asynchronously, the load can interfere with other processes. Also, this means that it is impossible to start 2-3 processes at once on weak devices, since the delay simply increases several times.
In an empty project, I can destruct several stones without lags (20 fragments, 1 piece per frame). I am afraid that in a project in which many processes are already running, an additional few milliseconds may create lags. But maybe this is not so. I need time to integrate this into my project.
Although, maybe I did not find it, and asynchrony can be used somehow?
P.S. I have almost all plugins for fragmentation in runtime from the Asset Store. In any case, even in this state, without asynchrony, this is the fastest plugin at the moment, if I need fast fragmentation of 25+ pieces and support for several materials, and without random GC spikes. I will embed it in my project and will return here for a review.
Is there a reason why the library does not work on x86, but only works on x86_64 builds?
Hi, thanks for feedback, this is what I really need right now to make it better.
About spike at the End, it happens because at the end it finally creates all frament gameobjects, applies meshes, creates convex sim colliders, etc. I will fix this by optional choice to not only cache meshes every frame, but also creating fragments, so fragments also will be created every frame and not at once at the end.
About asynchrony, yes, this is also will be added in next build, right now every Rigid have no idea about other Rigid components going through Runtime Caching. In next build there also will be optional feature which will make sure that there is no more than one Rigid which cache fragments atm, other will wait they turn in queue.
About x86, well, to be honest no one asked yet about x86 support and so far I try to add what people need the most, so it also will be in next build.
That was first Runtime Caching implementation, I just wanted to make it work with basic functionality and improve later after getting some feedback from real game developers, well, didn't expect to get it so quick. Adding all these little impovements will not be too hard.
@Mir-vadim I have a question about the basic workflow to create a basic cube, set it as a prefab precache and then hit play and press demolish.
I've been struggling to get prefab precache to work in my level so I am starting with just a simple cube and trying to nail down the process so I can implement RayfireRigid into my existing level prefabs.
Here is my attempt so far that do not work :
1. Create a new cube
2. Add RayfireRigid component to cube
3. select Demolition Type Prefab Precache
4. Press Prefab Precache button
5. Get Error
UnassignedReferenceException: The variable transForm of RayfireRigid has not been assigned.
You probably need to assign the transForm variable of the RayfireRigid script in the inspector.
UnityEngine.Transform.get_rotation () <0x2e2b272f7c0 + 0x00072> in <2ce230928a98496ba12ca183760fb5f6>:0
RayFire.RFFragment.PrepareCacheMeshes (RayFire.RayfireRigid scrRigid) (at Assets/RayFire/Script/Class/RFFragment.cs:77)
RayFire.RayfireRigid.CacheInstant () (at Assets/RayFire/Script/RayfireRigid.cs:490)
RayFire.RayfireRigid.PrefabPrecache () (at Assets/RayFire/Script/RayfireRigid.cs:422)
RayfireRigidEditor.OnInspectorGUI () (at Assets/RayFire/Script/Editor/RayfireRigidEditor.cs:78)
UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501)
Would love to know what I am doing wrong and what the process would be. Great plugin overall and I look forward to figuring out how to make it work and implementing in my game.
Hi, sorry, but this is a new bug in build 1.06, I rewrote almost whole Rigid component to add Runtime caching and added new bug, tomorrow I will send you a link to fixed package.
This is a great looking asset, have been drooling over it for a few hours now. I only take up Unity development as a hobby and it's rather hard to justify spending so much on an asset (it does seem to be worth it tho). So before I make a purchase I do have 2 questions:
1. Is there a lite/limited/watermarky/timebombed version that I can try before I buy?
2. Is it possible to have a building collapsing when say one of the pillars is broken or a side wall is collapsed? I have seen callouts here and there but have not seen a video example. Don't actually need a video, just a (semi)-detailed description if available.
Since I can't reach the developer via mail.
Could someone maybe tell me if this asset works with Unity 2018.1.1?
The store page states that you would need Unity 2018.4.6, but another user already confirmed that it also works with 2018.2.2 if you apply a little fix.
Hey, sorry for delay, we worked hard here on next release which will improve fragmentation process, some users complained that they can't fragment complex hi poly meshes, so we basically wrote second fragmentation mode for such objects for in Editor fragmentation. I was so busy that forgot to reply to emails all the time. It will be released on next few days.
Yes, it works with any 2018 build.
And by the way, I can't find email from you, where did you send it and when?
Thanks for the info! We will heavily consider buying it then.
I wrote one via the form on your homepage last week and one to the email address published at your homepage yesterday.
We bought the asset but instantly struggle a bit, integrating it into our project.
We have our own projectile system. On collision between a RayFireRigid and our projectile we simply call:
That demolishes the object, but it just collapses and does not get blown away like we want to. We tried to recreate the RayFireGun behavior but were not able to do so. How can you locally apply force when demolishing an object?
We were able to solve the issue by using the RayfireBomb component with small values at the impact point of the bullet.
My next question is:
Is it possible to have - for example - a big shelf, that the player can push around like a normal Rigidbody and as soon as the bullet hits a part of the shelf, only those parts get demolished and fall down?
If not - is it at least possible to have - for example - a big shelf, that is static in the world and can not be pushed by the player in any way, unless he shoots at it, so that parts of it fall off? The only way for me to get this working was to set the RayfireRigid to Kinematic, but then the player cannot collide with the object anymore. The column in the gun tutorial scene, for example, does not need to be shot to collapse, you can just walk into it.
And lastly a quick question:
If you shatter an object and then assign a RayfireRigid to the root, all the fragments get rigidbodies assigned at startup. In our case, their mass is way too low. How can you modify the mass of the created fragments?
Sorry for all the questions, but at the assets price point, I think it's fair to ask them. Your product makes a good first impression, but I think that there are many missing or not well enough explained features, that you could improve on.