- Home /
Question by
spels47 · Apr 15, 2019 at 12:32 PM ·
c#script.particle system
how do i change the rotation of an objects particle system shape in script?
i have tried this and a couple of variations so far:
var MySystem = Target.gameObject.GetComponent();
var Shape = MySystem.shape;
var Emission = MySystem.emission;
var MyRotation = Shape.rotation;
MyRotation.Set
(
Target.position.x - transform.position.x,
Target.position.y - transform.position.y,
Target.position.z - transform.position.z
);
Emission.SetBursts(new ParticleSystem.Burst[]
{
new ParticleSystem.Burst(0,3,1,1,Mathf.Infinity)
});
MySystem.Play();
Comment
Best Answer
Answer by spels47 · Apr 15, 2019 at 02:40 PM
fixed it by putting the references to the particle system in variables
var Test = Quaternion.LookRotation(Target.position - transform.position).eulerAngles;
var MySystem = Target.Find("TurretDamage").GetComponent<ParticleSystem>();
var MainSystem = MySystem.main;
var Shape = MySystem.shape;
var Emission = MySystem.emission;
MainSystem.gravityModifier = 0;
Shape.rotation = new Vector3(0f, Test.y, 0f);
Emission.SetBursts(new ParticleSystem.Burst[]
{
new ParticleSystem.Burst(0,5,1,1,Mathf.Infinity)
});
MySystem.Play();
Your answer
![](https://koobas.hobune.stream/wayback/20220612195517im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How can i prevent from mouse to collide with thirdpersoncontroller ? 0 Answers
Brackeys EnemyAi Script 0 Answers