Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamically created MBEmitter doesn't respect Billboard setting
#1
Hello! I've been using Curvy and Magical Box together to create a little partical flow from one point to the next. I generate both the spline and the MB settings in code and have the particles set to Billboard (as the camera rotates around, and I want them always facing the camera). This all works great and looks awesome in the Unity editor. I was trying to cut a test build for PC and noticed that the particles were not billboarding.

After putting in several Log points, I can clearly see that Billboard IS set for the MBEmitter and it persists all the way through the case statement that checks for billboard state, but for some reason the particles just don't seem to want to behave. Has anyone else had this issue and possibly found a way to resolve it? If it'll help, here is the code I use to generate the spline and MB Particle system:



Code:
var gospline = _splineGO = new GameObject("Spline");
var cs = gospline.AddComponent<CurvySpline>();

var frag1 = new Vector3(transform.position.x, transform.position.y, transform.position.z);
var frag3 = new Vector3(Globals.FocusObject.transform.position.x,
Globals.FocusObject.transform.position.y + 6,
Globals.FocusObject.transform.position.z);

var frag2 = Vector3.Lerp(frag1, frag3, 0.5f);
frag2.y += 15;

cs.Add(frag1, frag2, frag3);

Spline = cs;
Spline.RefreshImmediately();

var go = new GameObject("MBParticleSystem");

go.transform.parent = _splineGO.transform;

var mbps = go.AddComponent<MBParticleSystem>();

mbps.Duration = 11;
mbps.ParticleBlocksize = 20;


mbps.TextureAtlasPath = "Assets/ManaFlow.png";

var gol = new GameObject("MBLayer");
var mbl = gol.AddComponent<MBLayer>();

var mblr = mbl.GetComponent<MeshRenderer>();

mbl.RenderQueue = 3000;
var mat = Resources.Load("ManaFlow", typeof(Material)) as Material;
mat.mainTexture = Resources.Load("ManaFlow", typeof(Texture)) as Texture;

//mblr.material = new Material(Shader.Find("Particles/Additive"));
mblr.material = mat;


var goEm = new GameObject("MBEmitter");
var mbem = goEm.AddComponent<MBEmitter>();


mbem.Layer = mbl;
mbem.Duration = 11;



Texture2D tex = null;

tex = Resources.Load("ManaFlow", typeof(Texture2D)) as Texture2D;

mbem.Textures.Add(tex);

var mbsph = goEm.GetComponent<MBSphereEmitter>();


mbsph.Scale = new Vector3(1, 1, 1);
mbsph.Heading = MBEmitterTypeHeading.Fixed;
mbsph.FixedHeading = new Vector3(1, 0, 0);
mbsph.FixedHeadingIsGlobal = true;
mbsph.Arc = 0;
mbem.LaunchRate = 50;

mbem.Billboard = MBBillboard.Billboard;

var gopcsp = new GameObject("CurvySplinePos");
var pcsp = gopcsp.AddComponent<MBParticleCurvySplinePosition>();
pcsp.AnimatedLife = true;
pcsp.Order = 160;
pcsp.Extrusion = MBParticleCurvySplinePositionExtrusiuonMode.Tube;
pcsp.ExtrusionEvenlySpread = true;
pcsp.ExtrusionDistributionPoints = 8;
pcsp.ExtrusionRadius = 0.5f;
pcsp.TangentOrientation = true;
pcsp.Spline = Spline;

var gocf = new GameObject("ColorFixed");
var pccf = gocf.AddComponent<MBParticleColorFixed>();
pccf.transform.localScale = new Vector3(4, 4, 4);
pccf.AnimatedLife = true;
pccf.Order = 40;
pccf.AutoFade = true;
pccf.FadeIn = 0.15f;
pccf.DieOnAlpha = true;


pccf.Colors.Add(new ColorKey(0, GetComponentInParent<Hex>().Color));
pccf.Colors.Add(new ColorKey(1, Color.gray));

var gov = new GameObject("Velocity");
var pcv = gov.AddComponent<MBParticleVelocity>();
pcv.transform.localScale = new Vector3(4, 4, 4);
pcv.Order = 50;
pcv.Base = 3;

gov.transform.parent = goEm.transform;
gocf.transform.parent = goEm.transform;
gopcsp.transform.parent = goEm.transform;

goEm.transform.parent = go.transform;
gol.transform.parent = go.transform;

Thanks for your time and any help you might be able to provide!

ClosedEyesSeeing

EDIT: Also, it is important to note that I'm a novice Unity developer, so I could just be doing something wrong. Smile
Reply
#2
For those that may have an issue similar: I have solved my issue!

Jake requested a sample project (since he is busy making Curvy 2.0 awesome) and I found the billboard to be honored just fine in build.

It turns out that my GUI Camera was being set to current and MBParticleSystem was looking for current over main, so all the particles were billboarding to the wrong camera. It is interesting that this wasn't happening in the in-unity playmode, but I've forced the ParticleSystem to take main always and it has resolved my billboarding issue. Smile

Cheers,
ClosedEyesSeeing
Reply
#3
Interesting, yes, but not strange, because inside the editor there's a sceneview camera [img]images/smilies/wink.gif[/img]
Reply
#4
'Jake' Wrote:Interesting, yes, but not strange, because inside the editor there's a sceneview camera [img]images/smilies/wink.gif[/img]

 

Ah, that is good to know! Thank you!

 
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  gizmo doesn't appear !?! p6r 6 9,389 07-25-2011, 09:51 AM
Last Post: p6r

Forum Jump: