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 Alessio89 · Nov 20, 2014 at 04:49 PM · physicsparticle systemshuriken

Make Shuriken Particle System lock on to a target

Hi! I'm back with another issue that's really puzzling me.

I have a Fireball particle effect made with shuriken and it is awesome. The only downside is that the effect travel on a straight line. So I attached a script on the particle system that will handle the rotation, curvature and velocity in general.

What I do is: 1. Get the particles in the system 2. Cycle through the particles and adjust the velocity 3. Reassign particles to the system

That seems pretty obvious to me. Now, since I want the particle effect and trails to lock on to a target, I add a steering force to every particle in the system. Sadly, this doesn't produce the expected result. Instead the particles drift away from the target, like if a magnetic field was around the target and the particles were made of pure iron.

             ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particleSystem.particleCount];
             particleSystem.GetParticles(particles);
             for(int i = 0; i < particles.Length; i++)
             {
                 Vector3 dir = target - particles[i].position;                
                 dir.Normalize();
                 particles[i].velocity += dir * Time.deltaTime * 10; 
             }
             particleSystem.SetParticles(particles, particles.Length);



I'm surely missing something obvious here, but my brain refuses to work and I can't get this to work.

Comment
Add comment · Show 2
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 Anxo · Nov 20, 2014 at 05:56 PM 1
Share

taking a guess, could it be b/c you are adding to the already existing velocity ins$$anonymous$$d of defining it?

Also, I would throw this into fixed update and get rid of the time.deltatime. Try something like this in fixed updtae.

 particles[i].velocity = dir * speed;

I am guessing that the particle system is applying a force that you do not want. $$anonymous$$ake sure your particle system does not apply any force over time.

If you want a more gradual thing, you could say the current particle's velocity transitions to dir over time Vector3.$$anonymous$$oveTowards( current velocity , wanted velocity, smoothness);

What do you think?

avatar image Alessio89 · Nov 20, 2014 at 06:09 PM 0
Share

Actually i figured it out (kinda): it was because the simulation space was set to local ins$$anonymous$$d of world (even though i was sure that i switched it to world, but whatever) :D it needs a lot of adjustement because the fireball shoots over the target and then come back, starting an orbit movement. But I suppose I'll just check for the distance with the target and adjust the force accordingly :D

Thanks anyway for the tips, I'm going to move everything into fixed update, it makes more sense :)

0 Replies

· Add your reply
  • Sort: 

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

27 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

Related Questions

Water physics in solid object 2 Answers

How to make particles react to movement of particle system 4 Answers

Add collision planes to Shuriken ParticleSystem prefabs 1 Answer

Particles seem to be "masked" by geometry 0 Answers

Separate particle systems rendered together with a single sorting mode? 0 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