Good morning, I want to mount an if statement as follows:
I have the xInicial position and the xFinal position.
My goal is for the object to go from xInitial to xFinal, adding in positive and when it reaches xFinal, add up in negative and when it returns to the Initial x, more of the same.
In summary, go from xInicial to XFinal as if it bounced.
Any ideas?
xinicial = 0;
xfinal = 5;
void update(){
if(xinicial < xfinal){
xinicial += 1;
}
}
The idea is that when xInicial is = 5 then subtract to 0 and then again to add, infinitely.