Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Cap · Jun 02, 2010 at 12:24 AM · velocityaddforceacceleration

Problem matching particle & object velocities + speed

I have a scene with a ship that currently has an ellipsoid emitter attached to fire particles (as projectiles) directly forward using the emitter's Local Velocity value. This works fine and the emitter rotates along with the ship when it is stationary, however once the ship is moving the particles either lag behind, travel too fast ahead of the ship, or a combination of the two (varying with each particle, I think that may just be a glitch).

I tried setting the Emitter Velocity Scale to 1, hoping they would begin with the ship's velocity and then add their own Local Velocity value to that in order to maintain the same speed as when stationary, however this creates the unwanted acceleration. Am I right in thinking this is because I'm using AddForce to accelerate my ship rather than changing its velocity directly? Note that this happens even when no force is being added and the ship is simply continuing forward at its current velocity. If AddForce is the cause, is there any way to continue to use it and still keep the particle velocity in line with the ship velocity?

Thanks.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ken 2 · Apr 27, 2011 at 03:14 AM

Oh, of course as soon as I commented I realized how to do it. I made a script that sets the world velocity of the emitter (ie the gun) to the same as the target (ie the ship). Add the script below to the same gameobject as your emitter, and drag the 'ship' into it as the target. In this case it's a rigidbody because it's easy to get the velocity.

public class InheritParentVelocity: MonoBehaviour {

 public Rigidbody target;
 private ParticleEmitter theEmitter;
 public bool inheritParentVelocity=true;

 void Start()
 {
     theEmitter=transform.GetComponent<ParticleEmitter>();
 }

 void Update ()
 {
     if(inheritParentVelocity)
         theEmitter.worldVelocity = target.velocity;
     else
         theEmitter.worldVelocity = Vector3.zero;
 }

}

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
0

Answer by qJake · Jun 02, 2010 at 02:14 AM

I'm not sure if this is the effect you want, because I had a hard time understanding your explanation, but try (un)checking the Simulate in worldspace? checkbox. This means your particles will basically either exist in global or local space, and it sounds like you want the latter.

Comment
Add comment · Show 7 · 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 Cap · Jun 02, 2010 at 06:19 AM 0
Share

Sorry about the explanation, it's quite difficult to put into words. I need simulate in worldspace checked because the emitter is meant to be a gun, with each particle representing a single shot. The problem is that the velocity of the particles generated once the ship has any velocity at all doesn't inherit the velocity of the ship as the baseline and then add the particles' own local velocity to that. It seems like it's taking the ship's velocity and multiplying it by something, only I don't know what. Description of setup follows:

avatar image Cap · Jun 02, 2010 at 06:24 AM 0
Share

Duplicate this by creating an object moving along a single axis & adding an elliptical emitter with $$anonymous$$/max energy of 5, local velocity of 2 (along the same axis as the object's movement, z in my case), emitter velocity scale of 1, and allowing the moving object to rotate (taking the emitter with it) without altering its direction of movement (ie it can spin left and right as it moves forward). As you speed up the object, the speed of the particles increases on a curve. The particle stream also keeps following the object's movement vector rather than the axis assigned in local velocity.

avatar image qJake · Jun 02, 2010 at 06:43 AM 0
Share

Oh, you want to add the velocity of your moving ship to the particles, yet still have them exist in world space, I understand... did you try adding your particle emitters as child game objects, and then attaching those to the ship? Beyond that, you'd probably have to script the particles manually, calculating the resulting force vector for the particles based on the ship's movements.

avatar image Cap · Jun 02, 2010 at 08:19 AM 0
Share

Yes that's what I'm after. The emitter is attached to an empty gameobject that is a child of my ship, and that's what gave me this result. Scripting the particles sounds like rather a lot more work than just instantiating a plane with my particle texture on it and giving that a particular constant force from birth. I'll probably have to do it the hard way in the end anyway though.. Thanks for your help :)

avatar image Aron · Aug 19, 2010 at 09:32 PM 0
Share

Question: How would I solve this same problem, but have the instantiated object exist in local space to the ship? I'm having issues getting this to work. When I instantiate the object it doesn't parent itself to the launcher (I have attached to the ship object), but that's what I'd like it to do. Is there a way to instantiate a rigidbody as a child of the launcher, so that all it's transformations happen relative to the ship itself? I describe my problem a little more at:

http://answers.unity3d.com/questions/18553/proper-inertia-on-projectile-in-starfox-like-game

Show more comments

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

No one has followed this question yet.

Related Questions

Obtaining Constant Speed with AddForce 1 Answer

Constant force motion: s = s0 + v0 * t + a0 * t * t. Why? 1 Answer

Accelerate a rigidbody towards max speed 2 Answers

different beetween transform.translat and rigidbody.addforce? 1 Answer

How do i make the Impulse i give to my Player not be lowered by acceleration of gravity? 1 Answer


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