Well my dear, what you require is the use of "sin" or "cos"
these 2 deviate between 1 and -1 as the value increases.
Example would be
Object => Set Y position to (Y co-ordinate to deviate from) + (max pixel deviation)*sin(x)
for 0<=x<=360
anything outside this range is obsolete, as the pattern is symmetrical.
The max pixel deviation is how many pixels you want it to go up or down by.
However, do note that decimals will occur, so if it appears jumpy, you're not compensating for decimal values. (you also cannot have a fraction of a pixel)
Originally Posted by cec¿l i can do this without an animation but require one alterable value and one flag!!!!!
Is that a problem? Don't be afraid of alterable values You'll probably need to use at least one to get the effect you want here.
The best solution (in MMF2) I can think of is:
Always > Set Y to 200+(Sin(timer/2)*3)
where 200 is the Y coordinate you want it to hover around, /2 slows it down, and *3 increases the wave height. If you're creating the object in a location that's not fixed then you'll have to set an Alterable Value to the initial Y coordinate instead of using 200.
my demands have increased. i will now require 2 actives, 2 alt variables, and one flag. its smooth but id go with the trig.
but i must say i quite like the way it looks sitting there, all floaty like.
its simple highschool math edwin. sin or cos functions are waves. as x increases or decreases to infinity y increases and decreases between 1 and -1. its cyclic so it goes on forever. how would he NOT figure that out?
the only problem i have with it is what he mentioned. it appears jumpy because of decimal values of you dont compensate.
n/a
Dustin Gunn Gnarly Tubular Way Cool Awesome Groovy Mondo
Registered 15/12/2004
Points 2659
27th February, 2008 at 05:46:28 -
Originally Posted by Edwin Street Thanks guys but nim sold it in a perfect equation: Always > Set Y to 200+(Sin(timer/2)*3)
But I mean, seriously, how did you figure that out!?
Learn sin and cos well, they're the most useful math functions for games ever
n/a
Deleted User
27th February, 2008 at 14:53:39 -
Cecil, it appears jumpy because you're using the timer as a counter (which is independent from the frame rate), not because decimals are not being "compensated". And it would appear jumpy if you multiply the radius by 40+. Otherwise, it looks smooth.
well im not using the timer. nim is. im not even using trig. =P
and i was just repeating what not clubsoft said.
but yes. in tgf it will be jumpy (or in my opinion probably doesnt work at all without advanced math object and a decimal offset) because of decimals regardless of the timer.
Originally Posted by cec¿l well im not using the timer. nim is. im not even using trig. =P
Cecil, maybe you'd like to explain your situation more, or start a new thread, because the solutions posted here were in response to the original question by Edwin. I'd be interested to see how you're doing this without trig (and why..)
For the record, TGF doesn't have any trig functions. I don't even know if it includes the "timer" function. So yes, you'd have to use the Advanced Math Object.
well a new thread is highly unnecessary.
its basically 5 events. 4 active specific events and 1 always event
ill base it around a single y point to get rid of the second active (shadow) im using.
+always => set y("active") to 200 - Value A("active")/5
+flag0 is on => add 1 to Value A("active")
+flag0 is off => sub 1 to Value A("active")
+Value A("active") > 75 => set flag0 off
+Value A("active") < 25 => set flag0 on
that makes it float around the y coordinate of 200 at a nice speed (thats where the divide by 5 comes in) smoothly.
timer IS in tgf. timer count in 1/1000 sec 1/100 sec seconds minutes and hours since the start of level.
and why not?
if you can do it without trig or extensions in very few events and vars then more power to ya...me...