This is Sine and Cosine waves, for if you want to make a bullet or an enemy that follows a sine or cosine wave.
Usage:
sinWav(speed, time);
cosWav(speed, time);
Speed is how fast it moves, time is how long it stays going in 1 direction :3
IMPORTANT!!!
You must click "Variabels", then click "Add", and make an actor variable named "a", to prevent glitches
- Code: Select all
void sinWav(double vel, double heights)
{
a++;
if (a>=heights*2){
a = 0 - (heights / 1.5);
}
if (a<heights/1.5 && yvelocity>-vel)
{
yvelocity-=(vel/2);
}
else if (a>=heights/1.5 && yvelocity<vel)
{
yvelocity+=(vel/2);
}
}
void cosWav(double vel, double heights)
{
a++;
if (a>=heights*2){
a = 0 - (heights / 1.5);
}
if (a<heights/1.5 && xvelocity>-vel)
{
xvelocity-=(vel/2);
}
else if (a>=heights/1.5 && xvelocity<vel)
{
xvelocity+=(vel/2);
}
}
ENJOY !
Video:
Screenshot: