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 Lairinus · Feb 11, 2014 at 01:42 PM · c#particle animation

Get Height of Particle System

Morning,

I'm making an obstacle system. I have a float inactive height and a float active height for the resting / active height the obstacle will move to during animation. This works for every obstacle except the ones involving a particle system, as there's no actual height field for the particle system.

How can you calculate the height (in world space) of the particle system?

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

1 Reply

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

Answer by wibble82 · Feb 11, 2014 at 02:01 PM

You can get all the particles in the particle system using particlesystem.GetParticles. This gives you an array of Particle objects, each of which has a position.

If you get the list of particles, run over each of their positions and calculate the highest and lowest y coordinate, then the height is highest-lowest.

Is that what you're after?

Comment
Add comment · Show 6 · 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 Lairinus · Feb 11, 2014 at 02:19 PM 0
Share

Thanks for the suggestion, but I'm more after setting a height than getting a height. $$anonymous$$now any ways I could do something like ParticleSystem.Height = x ?

avatar image wibble82 · Feb 11, 2014 at 03:03 PM 0
Share

What would what setting a particle system's height do exactly? Its ultimately just a point in space that emits particles so doesn't have a height as such. At any given time you can work out the bounding volume of the particles its emitted, but there's no height to 'set' exactly. $$anonymous$$aybe explain what you want this height value to do?

avatar image Lairinus · Feb 11, 2014 at 04:35 PM 0
Share

I'm making a platformer.

I have randomly generated obstacles that include obstacles that require particle systems (like a flame trap)with semi-random parameters including height, frequency that it'll go off, and damage that it'll do when it goes off.

I don't want all of the flame traps to be going off at the same height, so I need to adjust the height in some way ins$$anonymous$$d of pre-setting the specific level instance. For example, when the level is loaded one time I want

  1. Trap 1 - height of 10

  2. Trap 2 - height of 20

  3. Trap 3 - height of 5

  4. Trap 4 - height of 10

Then when I reload the level a second time, I want it to be something like

  1. Trap 1 - height of 20

  2. Trap 2- height of 5

  3. Trap 3 - height of 40

  4. Trap 4 - height of 30

I hope I clarified its' purpose enough.

avatar image wibble82 · Feb 11, 2014 at 05:58 PM 0
Share

I see. Well the particle system is really just a visual effect on the 'fire ball' that gets shot upwards. Personally I'd do this with 2 game objects:

  • a fire trap object, with a script on that every now and then generates a fire ball object (with its own script)

  • the fire ball object has a script attached that causes it to die after a period of time, and also has 1 or more particle emitters on that leave a trail of burning fire behind you!

That way, you can use the physics to detect when the fire ball hits the player and use it to deal them damage. Ultimately though the key is that the particle system is just a visual that is attached to the fire ball.

Does that make a bit more sense?

avatar image Lairinus · Feb 11, 2014 at 07:10 PM 0
Share

Yes, what you're saying makes sense.

I guess I got a little bit too over-zealous when I found out about OnParticleCollision(GO c). It has the exact effect that I want without the height aspect which makes it hard to manipulate in my specific scenario.

As far as your suggestion -- that actually sounds like one of my other traps (aside from the trail of fire, which could be cool. Trail of flying javelins might be a little weird, though) but I'm going to change this trap from a stationary flame that starts and stops to maybe an elevated object that rises and recedes.

Thanks for all your help. I do appreciate it! I'm going to screw around with it a little bit when I get home and see if I can somehow get the effect but I want but I'm assu$$anonymous$$g I can't. In that case, I'll do the previously mentioned thing of changing up the traps.

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

19 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Renderer on object disabled after level reload 1 Answer

Extinguish fire with water particle system 0 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 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