#Is there a way to use saved particles and have them shoot out of guns?
1 messages · Page 1 of 1 (latest)
I can copy all that!? holy crap thats awesome thank you Holden👍
I have so many questions about the gun particles. is there a way to make the actual projectile hit mob? its hitscan like Halo AR
And I cant turn off the gun sound when I shoot a particle out of it which is a massive problem. Can the gun sound be turned off?
Can I also make it stop when it hits a block or mob? seems to go through blocks
Theres a couple ways to make the particles "collidable."
If it is a fast moving object like a bullet, you could probably calculate the distance between players (if hit) and then set the duration based on the distance (so it goes away when it reaches the target).
Another way is to generate particles in the line relative to your view until they reach the target (or until the for loop ends which decides how far it can travel). Here is a script using this method, but it does lower performance and if the particle is too complex, it will hit the particle cap easily (even after the particle is gone on screen it counts towards the cap for a moment longer):
Laser-Blaster_lua
local vx, vy, vz = get_view_dir()
local display = false
local range = 60
timer_reset()
timer_start()
local i = 1
//for i = 1, range do
while(i <= range) do
if intersect_ray(x + i * vx , y + i * vy, z + i * vz, x + (i + 1) * vx , y + (i + 1) * vy, z + (i + 1) * vz, false, true, display) then
set_context("target")
add_health_effect(-100)
set_context("actor")
exit()
end
if(get_timer() >= i * 16) then
//add particle here
for k = 1, 8 do
add_particle(x + (i + k * 0.1) * vx, y + (i + k * 0.1) * vy, z + (i + k * 0.1) * vz, 0.064, 0,0,0, 0.11,0.05,0.11,1, 251,24,24,25, 0,0, 0,0,0, 251,24,24,25, 0,0,0, 0,-0.075,0)
add_particle(x + (i + k * 0.1) * vx, y + (i + k * 0.1) * vy, z + (i + k * 0.1) * vz, 0.064, 0,0,0, 0.11,0.1,0.11,1, 251,102,102,25, 0,0, 0,0,0, 251,102,102,25, 0,0,0, 0,0,0)
add_particle(x + (i + k * 0.1) * vx, y + (i + k * 0.1) * vy, z + (i + k * 0.1) * vz, 0.064, 0,0,0, 0.11,0.05,0.11,1, 251,24,24,25, 0,0, 0,0,0, 251,24,24,25, 0,0,0, 0,0.075,0)
end
i = i + 1
end
wait(1)
end
performance also probably lowers from the amount of intersects too.
Other things to note, you could probably translate the same idea into colliding with blocks using get_block() at the particles coords. I dont think you can disable the gun/laser sound effects.
One other thing, Im not quite sure why the timer() parts are there, but if i remember correct it was to try to align the particles better so the beam remained consistent length by spawning it at the correct times. I think you could design it similarly without it.