Particle System won't emit properly.
Posted: Sun Mar 29, 2020 3:14 am
Hi. I've been working on my first LOVE2D project for a week or so and I'm trying to add some simple particle effects to the game.
The problem is that every emission call during the game results in particles shooting out on a specific axis, while the particles should just shoot out of the zombie's position in a radial manner. I've tried messing around with these functions listed on the documentation:
However both have not solved the issue as setDirection() only allows me to change which axis the particles fly out towards. I want them to fly out radially from my zombie instead. A terrible pseudo-code example to demonstrate the idea: pSystem:setDirection(random_angle_relative_to_center_of_zombie_object). Currently my code for the particle system is as follows:
I am just calling a simple pSystem:emit(numOfParticles) function whenever a bullet collides with a zombie. Any help with this issue will be appreciated, thanks.
The problem is that every emission call during the game results in particles shooting out on a specific axis, while the particles should just shoot out of the zombie's position in a radial manner. I've tried messing around with these functions listed on the documentation:
Code: Select all
pSystem:setEmissionArea()
pSystem:setDirection()
Code: Select all
particles = {}
function spawnParticle(x, y, speed, pSprite, pFX)
pFX.x = x
pFX.y = y
pFX.pSystem = love.graphics.newParticleSystem(pSprite, 20)
pFX.pSystem:setParticleLifetime(.5,1)
pFX.pSystem:setLinearAcceleration(-80,-80,80,80)
pFX.pSystem:setSpeed(speed/2, speed)
table.insert(particles, pFX)
return pFX
end
function particleUpdate(dt)
for i,p in ipairs(particles) do
p.pSystem:update(dt)
end
end