I want to achieve a special effect in Kanya dance, which you can see in this picture. Under the feet of the girl, there are particles flying up from that cicle, and fade out after it reach a certain height. The spawners of those particles keep randomly changing.
I would use sprites esp. if it is for a video game. No need to use actual particles. A simple plane with an animated particle on alpha background. Set the plane to always face the camera.
from bge import logic
import random
cont = logic.getCurrentController()
own = cont.owner
scene = own.scene
obs = scene.objects
spawner = obs["sparker"]
inac = scene.objectsInactive
sp = inac['spark-element']
def main(cont):
for sens in cont.sensors:
if not sens.positive:
return
#sp2 = sce.objects['spark2']
for i in range(0, 1):
#objects to add
ob = scene.addObject(sp, spawner, 100)
#object color
R = random.random()
G = random.random()
B = random.random()
ob.color = [R,G,B, True]
ob.scaling = [random.random(),random.random(),random.random()]
#object spawn
ob.applyForce((0, 1, random.randint(500, 1000)), True)
if __name__ == '__main__':
main(logic.getCurrentController())
thanks everyone
I made the python code above to spawm the sparkles. There is one empty that will rotate another empty, which is the spawner. The color and size of sparkles is also set randomly. The circle below is an animted texture with 16 frames.
If all your particles are coming from the same Z height, you could have their transparency based on their z worldposition, to have them fade out as they go up.
HEIGHT = 3.0 #the height particles fade to 0
Z = ob.worldPosition.z / HEIGHT + ((1.0-ob.localScale.x)*0.4) #vary fading by scale (thinner particles fade slower?)
ob.color = [R,G,B, Z]
From my experience though, altering the alpha levels of several objects tends to get expensive fast, so use with caution