Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jddg5wa · Dec 05, 2016 at 01:47 PM · errorparticlesystemparticle

[Tank Game Tutorial] Particles Only Appear While Turning

So I am following the tank game tutorial and have run into an issue with the particle system, happens on the included completed version too so it's not something I did. The dust particles for the tank tracks only work when turning. The particles do not appear when going forward or backward. What could be the cause of this? I have no idea since I am so new.

I recreated the particle system and it caused the same issues. I am not sure what needs to be done or what could be the cause.

gif showing issue: https://i.gyazo.com/ed25fbdfd1d50da5300e1e01c07c6bf8.gif

Thanks for any help.

Added per the suggestion of @ThePersister. The particle system settings and the tank hierarchy.

http://imgur.com/a/OJmFb

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ThePersister · Dec 05, 2016 at 11:47 AM 1
Share

Since the particles are fine. It's probably the code that is used to turn the particles on and off that is flawed. Could you copy your current code where it (likely) says particleSystem.Play() and particleSystem.Stop() and post it here in a comment or edit your main post?

Once you've done that I can help you out :)

avatar image jddg5wa ThePersister · Dec 05, 2016 at 02:13 PM 0
Share

There is no code running that particle system. The only thing that I can gather it's using is the particle systems own "Emission: Rate over Distance".

I should have mentioned this issue only appeared after I updated to Unity 5.5. I was using 5.4 before. I know the particle system had changes but I'm not aware enough of Unity to know what exactly and if it might have effected the tutorial.

avatar image ThePersister jddg5wa · Dec 05, 2016 at 02:26 PM 1
Share

Oooh interesting. I haven't gone beyond Unity 5.4 yet. Documentation here: https://docs.unity3d.com/$$anonymous$$anual/PartSysEmission$$anonymous$$odule.html

It says that if that rate per distance mode is active it will act based upon the movement of the Parent object. Now this may be a far guess, but perhaps there's a parent between the particle system itself and the core of the vehicle, like a left side parent or right side parent. And supposedly the particle system reacts to rotations as well, and those objects are only ever moved locally when they're rotated by the parent then that could explain the dust particles for rotational movement only.

Once again, that's a really far guess though.

$$anonymous$$aybe @Bunny83 knows more? :) (he should get a notification by this reference of $$anonymous$$e)

In the meantime, could you show the structure of the tank in the hierarchy? And perhaps the exact settings in your particle system, that might help the next person with figuring this out for you!

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by kevkevatthesev · Dec 27, 2016 at 11:16 PM

I'm using Unity 5.5.0, and I wasn't able to get the script @ThePersister wrote to work properly on its own for some reason, but I did successfully merge the code into TankMovement.cs, and it appears to be working. My solution doesn't exactly seem ideal, since the particle system is relying on the keyboard input, not the actual speed of the tank (But it looks ok).

I changed Update() to the following:


private void Update()
    {
        // Store the player's input and make sure the audio for the engine is playing.
        m_MovementInputValue = Input.GetAxis (m_MovementAxisName);
        m_TurnInputValue = Input.GetAxis (m_TurnAxisName);
        EngineAudio ();
        if (Mathf.Abs (m_MovementInputValue) < 0.1f && Mathf.Abs (m_TurnInputValue) < 0.1f) {
            _updateParticleSystem( m_leftDustTrail, false );
            _updateParticleSystem( m_rightDustTrail, false );
        } else {
            _updateParticleSystem( m_leftDustTrail, true );
            _updateParticleSystem( m_rightDustTrail, true );
        }
    }

And I copied the _updateParticleSystem function without any changes:


        private void _updateParticleSystem( ParticleSystem particleSystem, bool shouldBePlaying )
        {
            if ( particleSystem.isPlaying && !shouldBePlaying )
            {
                // Stop if currently playing and it shouldn't be.
                particleSystem.Stop();
            }
            else if ( !particleSystem.isPlaying && shouldBePlaying )
            {
                // Play if currently not playing and it should be.
                particleSystem.Play();
            }
        }
    }

Add new variables to the top of the class:


    public ParticleSystem m_leftDustTrail;
    public ParticleSystem m_rightDustTrail;

Do make sure that the settings for both particle systems are changed as mentioned:

"Right now you have Rate over Distance set to 10, set that to 0. And set Rate over Time to 10. Also, set Play on Awake to false. Do this for both dustTrail Particle Systems."

Hope this helps.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bigChris · Jul 14, 2017 at 05:59 PM 0
Share

Worked!!, Thanks so much for your efforts!

avatar image
0

Answer by ThePersister · Dec 06, 2016 at 10:02 AM

Hi @jddg5wa,

Thank you for providing the extra information. Since I can't upgrade to 5.5 right now to provide specific help, I'll give you an alternative solution.

This will work if the particleSystems are not stopped and played by other scripts. Attach the following script to the tank object:

 using UnityEngine;
 using System.Collections;
 
 public class TankParticlesExample : MonoBehaviour {
 
     public ParticleSystem m_leftDustTrail;
     public ParticleSystem m_rightDustTrail;
     private Rigidbody m_rigidBody;
 
     void Start ()
     {
         m_rigidBody = GetComponent<Rigidbody>();
 
         if (m_leftDustTrail == null)
         {
             Debug.LogError( "Don't forget to assign the LeftDustTrail in the inspector." );
         }
 
         if( m_rightDustTrail == null )
         {
             Debug.LogError( "Don't forget to assign the RightDustTrail in the inspector." );
         }
     }
 
     void Update()
     {
         // If velocity is greater than 0.5f, show particles, else, don't.
         if( m_rigidBody.velocity.magnitude > 0.5f)
         {
             _updateParticleSystem( m_leftDustTrail, true );
             _updateParticleSystem( m_rightDustTrail, true );
         }
         else
         {
             _updateParticleSystem( m_leftDustTrail, false );
             _updateParticleSystem( m_rightDustTrail, false );
         }
     }
 
     private void _updateParticleSystem( ParticleSystem particleSystem, bool shouldBePlaying )
     {
         if ( particleSystem.isPlaying && !shouldBePlaying )
         {
             // Stop if currently playing and it shouldn't be.
             particleSystem.Stop();
         }
         else if ( !particleSystem.isPlaying && shouldBePlaying )
         {
             // Play if currently not playing and it should be.
             particleSystem.Play();
         }
     }
 }
 

Make sure to assign the ParticleSystems in the inspector, just drag and drop. Right now you have Rate over Distance set to 10, set that to 0. And set Rate over Time to 10. Also, set Play on Awake to false. Do this for both dustTrail Particle Systems.

That should make it all work nicely. You can adjust the value of 0.5f to your needs, a higher value would require a greater speed before showing dust trails.

If it doesn't work, the Particle Systems are probably set to play and stop by other scripts. In that case you can remove the particle systems (temporarily) to find out where that happens, because if you remove them and run the game, you should get an error. Double clicking on that error will lead you to its origin.

With that, you should be able to get it to work. I hope this fulfills your request.

If this helped, please accept my answer, it'd be much appreciated!

If you need more details, let me know!

Best of luck!

Cheers,

ThePersister

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Did the behavior of gravity of particleSystem ever changed? 0 Answers

Wind Zones and External Forces causing crash after exiting game. 0 Answers

Teleporting old particle system 0 Answers

Start/Stop a Particle System 2 Answers

ParticleSystem at Photon Not working! 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges