In my 2D game, I've encountered a very specific task. I needed to create a "Bouncing Bullet Shells" effect for my particles. I found the perfect video to implement my idea, but it wasn't a tutorial, and the presented project didn't have open code. In the comments, the author provides a part of the particle shader script, but I couldn't understand it. Can anyone help me implement this or point me to similar tutorials? Thanks in advance to everyone who responds!
link to video -
The part of the code:
vec2 apply_bound(float y_in, vec2 vel){
if(y_in > bound){
if(abs(vel.y) < 20.0){
vel.y = 0.0;
}else{
vel.y = -0.75 * abs(vel.y);
}
vel.x = 0.0;
}
return vel;
}
Shader effect "Bouncing Bullet Shells" for Particles in 2D project.
Well the code you shared is for some vertically moving thing, it will slow it down and then stop it entirely. Also it makes sure the motion is purely vertical.
Not sure why it does that, though.