using UnityEngine;
using System.Collections;
public class carMuzzleFlash : MonoBehaviour
{
public ParticleSystem frontLeft, FrontRight;
public ParticleSystem backLeft, backRight;
public static carMuzzleFlash Static;
void Start ()
{
Static = this;
}
public float timeToWait ;
// Update is called once per frame
public void flashPositionfrontLeft ()
{
frontLeft.emit= true;
StartCoroutine ("stopFlash");
}
public void flashPositionFrontRight ()
{
FrontRight.emit = true;
StartCoroutine ("stopFlash");
}
public void flashPositionbackLeft ()
{
backLeft.emit = true;
StartCoroutine ("stopFlash");
}
public void flashPositionbackRight ()
{
backRight.emit = true;
StartCoroutine ("stopFlash");
}
IEnumerator stopFlash ()
{
yield return new WaitForSeconds (timeToWait);
frontLeft.emit = false;
FrontRight.emit = false;
backLeft.emit = false;
backRight.emit = false;
}
}
I need some help with this code
You need to read documentation.
https://docs.unity3d.com/ScriptReference/ParticleSystem.html
There’s no “emit” property in ParticleSystem class, but there is emission module.
You’re also posting in a wrong forum, you should’ve posted this in “Editor & General Support” or “Scripting”.
Theres no emit module, so can you state exactly what we should do to solve it? not all of us are coders, so please explain further as its not our fault that unity keeps making game breaking changes
Unity didn’t make a breaking change. There has never been an emit property. We can’t even blame ChatGPT for this mistake as it wasn’t around when this thread was created. So this is entirely user error. Another thing that’s user error (and against the rules) is reviving a thread just to make a snarky response rather than be helpful.
https://discussions.unity.com/t/757848
For anyone else that comes to this thread here is the corrected code.
GPT-4
using UnityEngine;
public class CarMuzzleFlash : MonoBehaviour
{
public ParticleSystem frontLeft, frontRight;
public ParticleSystem backLeft, backRight;
public static CarMuzzleFlash Static;
public float timeToWait;
void Start ()
{
Static = this;
}
public void FlashPositionFrontLeft()
{
frontLeft.Play();
StartCoroutine ("StopFlash", frontLeft);
}
public void FlashPositionFrontRight()
{
frontRight.Play();
StartCoroutine ("StopFlash", frontRight);
}
public void FlashPositionBackLeft()
{
backLeft.Play();
StartCoroutine ("StopFlash", backLeft);
}
public void FlashPositionBackRight()
{
backRight.Play();
StartCoroutine ("StopFlash", backRight);
}
IEnumerator StopFlash (ParticleSystem system)
{
yield return new WaitForSeconds (timeToWait);
system.Stop();
}
}
You’re not the OP, and the thread is over 2 years old.
The page I linked earlier:
https://docs.unity3d.com/ScriptReference/ParticleSystem.html
Contains definitions for all particle system modules and also provides examples of their use. With code.
And if you actually click on “emission” module documentation, there’s a code example.
https://docs.unity3d.com/ScriptReference/ParticleSystem-emission.html
No game breaking changer has been made. Also, you should learn to read documentation. This will save a lot of time you’d need to spend waiting for community help. Although now there are chat bots that can provide limited assistance.