###

» Sun Sep 22, 2013 2:12 am

[QUOTE=tulamide] You can just do your own sine-based movement. You need a variable (here 'sinangle'). Set it to 0 initially.

Calculate the center of the movement. Let's say x=200, while the total width of the movement is 300, for this example. The radius is half of the width = 150.

every tick -> add n*360*dt to sinangle

bird -> set x to 200 + sin(sinangle) * 150

that will make it fly back and forth from 50 to 350. You have to experiment with n, it is the speed factor.

Now that it runs, check sin(sinangle) for being close to +1 or -1. If it is +1 (or close to, might not exactly hit 1) the movement to the right is at its climax and will now turn to the left. If it's -1 exactly the other way round. Remember to use 'once while true' for those comparisons. That's all.[/QUOTE]

Edit: I was able to adjust some of the variables, and go it to work perfectly. Thanks! One question, why did you use n*360, why 360?Draspur2013-09-22 02:26:31