changing the radius of a particle system with unity script
I've looked at several different topics, but none of them worked for me. It should be super simple.. I thought, but I'm going loco here:
#pragma strict
private var oscScript : GameObject; // ref to initScripts which has the oscCreceiver
public var ps : ParticleSystem;// = GetComponent<ParticleSystem>();
private var _pos;
private var shape;
function Awake ()
{
oscScript = GameObject.Find("initScript");
// ps = GetComponent.<ParticleSystem>();
shape = ps.shape;
// Debug.Log(shape);
}
function FixedUpdate()
{
var i = 1;
_pos = oscScript.GetComponent.<oscReceiver>()._aa2;
var radiusShape = Globals._map(_pos, .0f, 1.0f, 0.0f, 15.0f);
shape.radius = radiusShape;
last line gives me the error: radius is not a member of 'object'
WHYYY
maybe Unity Script is not really in full support anymore. the new ParticleSystem is fairly new. Translating to C# shouldn't be too hard.
switching is recommended anyway
@hexagonius thanks for your comment! Are you sure about this? I'm not sure where to find any confirmation. I'm using some plugins to receive OSC in unity.. I can't be rewriting those too :)
why is switching recommended?
edit: can't find any unity script samples for sure :/
that's one reason why :)
and I'm quite busy in unity answers and have seen several complains about Unity Script already.
It's very seldom to see it also.
Answer by flowen_nl · Feb 24, 2017 at 10:40 AM
@hexagonius So I tried using C# but couldn't figure out how to share global variables between unity script and C#. Read that C# is compiled first so I wouldn't have access to the variables in Unityscript.
So I threw it all out and retried above script and it works for some magical reason
programerslife
only thing different is moving shape declaration to the update function
nice... great program$$anonymous$$g is so... logical :)
Your answer
Follow this Question
Related Questions
Particle System Particles Not Following Rotation 1 Answer
Moving particle system via script causes choppy movement in build but works fine in pay mode 1 Answer
While particle system is alive play animation. 0 Answers
Particle system only playing when visible 0 Answers
Particle System Prefab on collision? 0 Answers