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
8
Question by Berenger · Mar 04, 2012 at 04:07 AM · particlesrandomshurikencurve

Shuriken, change Random Between Two Constants by script

For several parameters, Shuriken is giving different ways to affect it in the editor : constant, curve, random, gradient etc. However, by script you can only affect a constant value, like for instance :

 system.startSize = 5f; // Can't specify a curve or a range, it's a float !

Is there some secret ninjas ways to do that, or do I need to do every frames :

 // Or curve.Evaluate(system.time/system.duration)
 system.startSize = Random.Range(min, max); 

As we are talking, among other things, about Shuriken's random stuff, here is an interesting paper (unrelated to the issue here, and yet kind of, as the result above won't be similar to the builtin one, because the random value is re-sampled, thus not connected).



[Edit] Apparently, when a float parameter is set "Random Between Two Constants", affecting a new value will set it as the second constant, and the first will then be firstValue * (lastSecondValue / newSecondValue). For instance, you set startSize in the inspector between 1 and 3. Then in Awake, you do startSize = 5; startSize is now between 1.66 and 5. It's empirical, so take it carefully. I didn't found any ways to set both values, or curves, gradient, two curves or two gradients.

Comment
Add comment · Show 9
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 Berenger · Mar 08, 2012 at 04:43 PM 0
Share

Bringing that question up, trying my luck ...

avatar image Berenger · Mar 16, 2012 at 04:56 PM 0
Share

Last time, I promess !

avatar image kromenak · Mar 21, 2012 at 06:24 PM 0
Share

I've found the script interface leaves some room for improvement - for example, interpolating a particle system between two states seems difficult. Sorry I can't help you, but want to note that I also struggle with this.

avatar image Berenger · Mar 23, 2012 at 03:40 PM 0
Share

I hope they are going to improve it in further versions, that's probably only the first step.

avatar image Berenger · May 03, 2012 at 04:56 PM 0
Share

Any news for this ? (up)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by yoyo · Jun 23, 2012 at 06:11 AM

Shuriken is a curiously dark box when looked at from a scripting perspective -- there are many parameters you can manipulate in the editor that are not accessible from script, even things as simple as the size of the emitter.

The best Secret Ninja Sauce(TM) I've found is to use the editor to create an animation that animates a particle system property from a minimum value at the start of the animation to a maximum value at the end of the animation, then from your script you can update the animation state using normalizedTime to select a value between min and max (0 for min, 1 for max).

You can get the animation state like this (probably best to do this in Awake or Start) ...

 AnimationState setScaleAnim = animation["setScale"];

And then set your value to (say) halfway between min and max with ...

 setScaleAnim.normalizedTime = 0.5f;

You can set up a bunch of animation states, one for each parameter (or set of parameters) that you want to procedurally control.

It's a little indirect, but it does give you scripted control of anything you can see in the Shuriken editor.

Comment
Add comment · Show 2 · 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 Berenger · Jun 23, 2012 at 03:07 PM 0
Share

Yup, that does sound like a good way around. Thanks :)

avatar image yoyo · Jun 24, 2012 at 03:18 AM 0
Share

I haven't tried it, but for bonus points it should even be possible to create and add AnimationClips procedurally, for full control.

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

8 People are following this question.

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

Related Questions

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

Shuriken OnParticledCollision 2 Answers

Possible to get particle positions with Shuriken? 1 Answer

ParticleAnimator doesn't change color of particles in ParticleSystem(Shuriken) 0 Answers

Shuriken ParticleSystem.Emit not immediate 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