Posted By
|
Message
|
eyeangle
Registered 12/06/2003
Points 1683
|
26th February, 2008 at 19:40:39 -
I need an object- 40x40, to float up and down a few pixels in mid air. I've tried path movment but it's not smooth.
Cheers.
theonecardgame.com
|
Ski TDC is my stress ball
Registered 13/03/2005
Points 10130
|
26th February, 2008 at 19:43:17 -
"Wingardium leviosa"
I'm sorry I couldn't help myself
n/a
|
AndyUK Mascot Maniac
Registered 01/08/2002
Points 14586
|
26th February, 2008 at 20:07:37 -
I don't think many people use equation for that, they just use animations... don't they? Well i would.
.
|
Cecilectomy noPE
Registered 19/03/2005
Points 305
|
26th February, 2008 at 20:21:20 -
i can do this without an animation but require one alterable value and one flag!!!!!
you got the goods?...
n/a
|
Joe.H Evil Faker
Registered 19/08/2002
Points 3305
|
26th February, 2008 at 20:36:50 -
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)
My signature is never too big!!!
|
nim
Registered 17/05/2002
Points 7234
|
26th February, 2008 at 20:45:59 -
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.
//
|
Cecilectomy noPE
Registered 19/03/2005
Points 305
|
26th February, 2008 at 20:46:08 -
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.
n/a
|
Cecilectomy noPE
Registered 19/03/2005
Points 305
|
26th February, 2008 at 20:47:21 -
it isnt a problem its just my demands!!! MWUAHAHAHA
n/a
|
nim
Registered 17/05/2002
Points 7234
|
26th February, 2008 at 20:49:34 -
I can't imagine what you're using the flag for, but I guess we all have our own way of doing things..
//
|
Cecilectomy noPE
Registered 19/03/2005
Points 305
|
26th February, 2008 at 20:56:44 -
well im not using trig. so the flag is for whether it goes up or down.
the extra active is just so it has a place to hover around. in my case i just made it a cube and a shadow. the cube hovers above the shadow.
and i got rid of the extra alt.
n/a
|
nim
Registered 17/05/2002
Points 7234
|
26th February, 2008 at 21:14:01 -
If you have a shadow object then perhaps you could try:
Always > Set Y("floaty") to Y("shadow")-100+(Sin(timer/2)*3)
No alterable values or flags required.
//
|
eyeangle
Registered 12/06/2003
Points 1683
|
26th February, 2008 at 21:16:56 -
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!?
theonecardgame.com
|
Cecilectomy noPE
Registered 19/03/2005
Points 305
|
27th February, 2008 at 00:28:45 -
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.
|
|
|