Quantcast
Channel: Questions in topic: "skinned mesh renderer"
Viewing all articles
Browse latest Browse all 192

Changing particles in particle system from local space of skinned character mesh to world space (unattached)

$
0
0
Hi, First off I'm still new to Unity, C# and Javascript - come from a Python/C++/Maya Scripting background. Not sure if this should be in the forum instead, but anyway. I'm currently working on a project in which I need to have particles attached to the vertices of a skinned (animated) mesh when they are created, but then they need to be in world space for every frame after that (end result will be sort of a ghosting effect!) I currently have it so that the mesh for the skinned character controller is being baked out each frame, its vertices are put into an array and these positions are passed to particles in a particle system (which is attached in the same place as the script but has been made inert), which is set every frame. So the particles follow the animated mesh around fine (there's a tiny bit of lag but I don't mind that for now). The only problem is the script is a component under the Bip001 Pelvis part of the default 3rd Person Controller, firstly so it can access the Skinned Mesh Renderer (needed for baking the mesh each frame) and secondly so it actually follows the position and orientation of the character animation. I tried putting the script into its own empty GameObject and accessing the necessary objects and components from there but it only introduced more problems! Is there any easy way to make particles that are instanced from a script parented under the character stop following it after they are spawned, essentially?? I know this is a fairly complex/confusing setup but any advice would be great. (Sorry for the crude image too! - and ignore the other Emitter, that was for testing) ![alt text][1] My other issue is that I think the particles are ignoring my assignment of attributes such as the size and instead go by the inert Particle System, when I both create them and update them based on the changing mesh - no idea why this is. Do the attributes for the Particle System Component in the Inspector take precedence over scripts? private void CreatePoints (Vector3[] verts, ParticleSystem.Particle[] points) { for (int i = 0; i < resolution; i++) { points[i].position = verts[i]; points[i].color = new Color(1f, 1f, 1f); points[i].size = 100f; points[i].lifetime = 1; } } public void SetPoints (Vector3[] verts, ParticleSystem.Particle[] points) { Debug.Log("Length of verts array"); Debug.Log(verts.Length); for (int ii = 0; ii < resolution; ii++) { points[ii].position = verts[ii]; points[ii].color = new Color(1f, 1f, 1f); points[ii].size = 1f; points[ii].lifetime = 1; } } [1]: /storage/temp/22812-helpunity.png

Viewing all articles
Browse latest Browse all 192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>