I am currently working on a SWEP that charges up and releases miniature black hole projectiles.
For it’s charging effect, I have a bunch of particles randomly spawning around the muzzle of the weapon and what I would like to do is have them all converge into the center of the muzzle as if they were being “sucked into” the projectile.
I am not quite sure how to accomplish this though, if anyone has any suggestions or ideas I would be more than appreciative.
I’m a bit rusty but I did something like this 13 years ago. Quantum Storage Device - YouTube
I’m not up to date with the latest GMod changes but I hope this will help anyway.
I assume you are already spawning particles randomly around the muzzle.
If you take the muzzle position (Let’s call it A), generate a random vector (lets call it B) and add B to A to get the position of the particle you spawn (we can call it AB).
If you normalize vector B (make it the length of 1) and multiply it by -1 (lets call this vector C) you get a direction. From the perspective of AB, C would point towards A (towards the muzzle).
If you have a particle spawn at AB and give it a velocity of C and the particle would go towards the muzzle (from the time the particle was spawned). If you multiply C by 10 it will go by the speed of 10.
Keep in mind you probably want to sync this with the lifetime of the particle. If you don’t, the particle will go through the center of the muzzle and continue outwards ruining the suction effect (you can see it in the video, i assume you want the particles to stop in the middle)
Since you know the distance from AB to A (length of B) and you decide the velocity yourself (the number you multiply with C) you can calculate the lifetime of the particles. If the distance is 10 (length of B) and the speed of the particle is 2 units per second it’s 10 / 2 which is 5.