The Daily Click ::. Forums ::. Klik Coding Help ::. Assigning particle trails positions to particle parents.
 

Post Reply  Post Oekaki 
 

Posted By Message

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
4th December, 2009 at 05:14:11 -

Hey there. I'm wishing to work on particle effects, especially impacts such as explosions. An effect I'm looking for is smoke trails coming off numerous pieces of shrapnel in the frame.
For one piece of shrapnel this is straight forward, just create the smoke particles and assign their positions and various effects relative to the desired piece of shrapnel. Fifty, or just two pieces of shrapnel becomes difficult, because you need to assign which smoke particle goes to which shrapnel piece, all with even numbers.
I've been working with spreading values, and have come up with a concept that I can work, but yet have I successfully created the desired effect.

Here's some psuedo-code to attempt to explain:

let n be any random number

let x be amount of shrapnel particles on screen at any time

//creates the desired amounts of shrapnel particles/objects
-user clicks
+execute explosion loop n times

//shrapnel properties are set, including IDs ranging from 0 to x number of shrapnel particles
-on explode loop
+create shrapnel particles
+assign shrapnel positions and velocities
+spread from 0, shrapnel IDs

//starts a smoke particle creation loop as many times as there are shrapnel particles, and moves the shrapnel pieces
-always
+execute smoke trails loop x times
+move shrapnel particles according to respective velocities

//creates x smoke particles and assigns their IDs evenly between all of the shrapnel particles
-on smoke trails loop
+create smoke particles
+spread smoke particle IDs evenly between 0 and x

//sets the smoke particle positions to the shrapnel pieces evenly
-if smoke particle ID is equal to shrapnel particle ID
+set smoke particle position to respective shrapnel particle

end

/


Now all this code works up to the last few lines, at the last condition. Essentially this comes down to one question, how do I assign the smoke particle IDs evenly between the shrapnel particle IDs, so every time the loop is executed, every piece of shrapnel receives 1 smoke particle?

Many thanks for any suggestions and help.

 
Especially that.

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
4th December, 2009 at 14:37:52 -

Why do all that when you can just use a simple

Always
-Create object smoke at (0,0) of "shrapnel"

Then it'll create the smoke at every piece of shrapnel at once!


You can handle the smokes moments in a separate piece of code, no ID's or spread values needed!

 
n/a

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
4th December, 2009 at 15:38:15 -

^ pretty much that. But don't use always; use "Shrapnel" count is greater than 0, or is within the frame.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
4th December, 2009 at 17:42:59 -

If you're doing a scrolling game, you should also limit it so that it's not too distant from the player or too distant from the center of the visible area. That way you don't have a ton of particles being created too far out of view, causing performance to drop.

 
http://www.facebook.com/truediamondgame

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
4th December, 2009 at 19:42:08 -

Ahh! Thankyou! I was having issues due to the fact that I wasn't setting the object creation relative to the spawn object. I was using position setting events that weren't working as the particles were created at an absolute position instead of relative to the shrapnel... so the smoke particles were being positioned only at the first instance of the shrapnel particle.

Cheers!

 
Especially that.

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
4th December, 2009 at 20:04:42 -

Wait... thankyou for your assistance but i'm having the same problem as before, the thing about what i'm doing is i want to perform operations on the smoke particles after they have been created, which is where the problem lies. i can spawn particles at every piece of shrapnel fine, i was doing that with the 'launch object' function, but i am using custom movements with float variables for positions for everything, including smoke particles.
so basically:

-the shrapnel particles are on screen with variable co-ordinates
-every frame a smoke particle is created at every shrapnel piece (this is fine for static smoke particles)
-once i perform operations such as scaling- relative to the parent shrapnel piece- problems occur, and only one smoke trail is scaled on screen at once

this is why i think i need IDs. because i need to keep clarifying which smoke particle came from which shrapnel piece. because once i start making post operations on the smoke particles that take data from the respective shrapnel piece, issues start arising from exactly which shrapnel piece they should take it from, as the only relative operation that works for now is the initial position the smoke particle is created at.

it's hard to make this totally clear so i hope you can understand what i'm trying to say. thanks for all the help!

 
Especially that.

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
4th December, 2009 at 20:21:50 -

You still do not need ID's

First do not use the "Launch an Object" command. Instead use "create object" and use the relative to function and set it to (0,0) of the shrapnel.

Then under the same condition, right after the object has been created, you can do things such as randomize the size, and position of the smoke particles.

If you are still having trouble later I'll create an example file for you.

 
n/a

Levirules



Registered
  27/09/2008
Points
  37
18th December, 2009 at 18:14:07 -

Sounds like you will need ID's. There was a recent post in this board about pairing objects, and someone said that MMF pairs objects just fine without messing with spreads as long as there are exactly as many parent objects as ...kid... objects (wth do you call them??). Personally, I think this kind of thing is one of those things that end up being messier in MMF than actual code.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click