Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by sstakoff · Dec 31, 2016 at 02:15 PM · particlestutorialemissiontanks

Tanks Tutorial - dust trails not emitted on MovePosition

I'm a newbie - working on the Tanks tutorial. Have been following along fine, but my tank dust trails are not working when the tank is moving forward and backward. The trails emit fine during the turning operation. I suspect this has to do with the difference between MovePosition() and MoveRotation() and their affect on the particle system. I have tried virtually every setting on the particle system - disabling all modules except the renderer and the emission over distance. When dragging the particle system in the scene view, the emissions appear correctly. But, when I click play and use the keyboard to control the tank, the particles only emit on turning - not on movement.

Using 5.5.0p3

Comment
Add comment · Show 1
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 GregoryFenn · Feb 20, 2018 at 08:48 AM 0
Share

After a lot of research I figured it out, but first I want to say a couple of useful thingst to learn:

See the modern Unity on the $$anonymous$$ovePosition function: https://docs.unity3d.com/ScriptReference/Rigidbody.$$anonymous$$ovePosition.html

Notice in particular "If the rigidbody has is$$anonymous$$inematic set false then it works differently. It works like transform.position=newPosition and teleports the object (rather than a smooth transition)."

In our game, this is the case. As such, we are not "moving" our tank forwards and back, rather we teleport it s tiny bit forwards and back. Therefore, the "velocity" of the tank (and therefore teh dust) at any infintesimal moment is 0. Because the tank is either just teleported and now taking a quick break, or is having a break while it waits to be teleported again.

This explains the problem.

After a lot of work on trying to manuelly "set" the velocity of the dust, I realised it was impossible (or at least, WAY too hard) because the computer always thinks the tank is at velocity (0,0,0).

The solution is either (hard) to encode a function into the dust that records the positions of the tank iver the last 30 frames or so, and works out the velocity that way....

OR (easy -- and better) look at the Particle System component of your dust objects (both left and right) and scroll to "Emiter Velocity". Change it from Rigidbody to Transform.

That solves it.

I'm sorry for not giving the answer so quickly, but I hope you learned a bit from this (and thank for as I spent over an hour on it this afternoon trying to work it out!).

4 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by GregoryFenn · Feb 20, 2018 at 08:49 AM

Look at the Particle System component of your dust objects (both left and right) and scroll to "Emiter Velocity". Change it from Rigidbody to Transform.

Comment
Add comment · Show 3 · 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 waldorodz · May 19, 2018 at 01:16 AM 0
Share

Great! Thanks! Changing the Emitter Velocity to Transform solves the problem! No need to modify the Tank $$anonymous$$ovement script...

avatar image steveeltham · Mar 27, 2019 at 03:11 PM 0
Share

Thanks GregoryFenn!

avatar image briosh · Oct 27, 2021 at 01:16 PM 0
Share

that was it for me! thanks

avatar image
4

Answer by DanielePattuzzi · Dec 31, 2016 at 03:13 PM

I am facing the same issue right now. I'm a newbie too, but it seems that MovePosition() doesn't affect the particles anymore (from version 5.5). I'm not sure but the Rigidbody velocity's properties doesn't update if the tank is moved by MovePosition(). Instead, using the AddForce() method the particles effect works (affecting the velocity property).

Comment
Add comment · Show 3 · 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 DanielePattuzzi · Dec 31, 2016 at 03:41 PM 0
Share

I've found this solution that seems to work. I've modified the tank $$anonymous$$ove() method in this way:

      private void $$anonymous$$ove()
         {
             // Adjust the position of the tank based on the player's input.
             m_Rigidbody.velocity = transform.forward * m_$$anonymous$$ovementInputValue * m_Speed;
         }




avatar image sstakoff · Dec 31, 2016 at 03:55 PM 0
Share

Interesting. Thanks for the reply. I am curious as to whether or not this is a feature or a bug. At least I know I'm not crazy!

avatar image gstarch · May 26, 2017 at 05:16 PM 0
Share

I tried your script and it worked in resolving the issue with the particle effect not working when not turning, but I found later on that it interfered with the tank's movement after shells hit close to it. Tank seemed to stop too soon. I tried all sorts of tweaks on the rigidbody, but eventually just went back to using the original Tank$$anonymous$$ovement.cs.

avatar image
1

Answer by SolsticeTeamGames · Sep 05, 2017 at 02:13 AM

Looks like you want to change the emitter velocity to measure Transform instead of Rigidbody, likely because MovePosition doesn't alter the Rigidbody velocity.

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
avatar image
1

Answer by nbLurkerAbove · Dec 12, 2017 at 07:50 AM

Disclaimer: At the time of writing, I have only completed up to the 5th section of the tutorial.

Using @DanielePattuzzi 's answer, I've fixed the problem of the explosion not pushing the tanks backwards enough, though I modify the game's behavior in the process. I believe the problem was that the modified move function (shown below) was overwriting the tanks' velocity from the explosion, resulting in the tank stopping after 1 physics tick.

  private void Move()
  {
      // Adjust the position of the tank based on the player's input.
      m_Rigidbody.velocity = transform.forward * m_MovementInputValue * m_Speed;
  }

My solution was to have the move function modify the velocity instead of overwrite it.

 public float m_maxSpeed = 10f;
 public float m_Acceleration = 0.5f;

 private void Move()
 {
     // Adjust the velocity of the tank based on the player's input.
     Vector3 velocity = m_Rigidbody.velocity;
     velocity += transform.forward * m_MovementInputValue * m_Acceleration;
     Vector3 direction = velocity.normalized;
     velocity = direction * Mathf.Min(Mathf.Abs(velocity.magnitude), m_maxSpeed);
     m_Rigidbody.velocity = velocity;
 }

What I do here is add an acceleration value to the velocity each tick depending on whether the input is forwards, backwards, or 0. I then cap this velocity with a max speed. The result is a tank that does not instantly change its speed, letting explosions push it around.

This change drastically changes how the tank handles, however. Increasing the acceleration brings the behavior closer to that of the original, but I have not figured out how to brake the tank (right now it just coasts to a stop)

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

100 People are following this question.

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

Related Questions

Unity 2018 Particles aligning to Tangent rather than Normal with align to direction 0 Answers

[Solved] Particles work only on the first time... Yes I have checked related posts... nothing works thou 1 Answer

Tanks Tutorial - Shells not firing properly 0 Answers

Low particle emission rate 1 Answer

How Play and Stop a ParticleSystem through Scripting? 9 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