Posted By
|
Message
|
Ando
Registered 08/04/2006
Points 100
|
28th April, 2011 at 19:59:32 -
Hey, guys.
So I've been messing with and picking apart Anders Riggelsen's realistic waving flag engine, and I'm loving it; I've managed to learn quite a bit from it! I've got it figured out for the most part, but there's one thing that's been giving me trouble. In a couple of the formulas, he uses a built-in MMF2 value called "timer". Can anybody explain what this does? (Or better yet, does anybody have a list of all of these MMF2 values? I've not been able to find one...) Since I don't know what "timer" is referencing, I can't figure out how exactly it's affecting the flag, so it would be very useful to have this explained.
Thanks!
P.S. One of the formulas that reference it, just in case it clarifies anything:
velX( "Front" )+Abs((Sin(timer/24-LoopIndex("a")*10)*Sin(timer/41-LoopIndex("a")*10)+Sin(timer/15)*Sin(timer/19-LoopIndex("a")*10))*200)
n/a
|
s-m-r Slow-Motion Riot
Registered 04/06/2006
Points 1078
|
28th April, 2011 at 21:53:08 -
Things I would do in this order:
--Check any "Always" commands and see if they reference a Global Value labeled as "timer"
--See if any events start the Timer, which shows up as a stopwatch in the event list
All things considered, my gut tells me that it's the first of these two. I've not seen the engine you're talking about, but it looks interesting.
n/a
|
Ando
Registered 08/04/2006
Points 100
|
29th April, 2011 at 12:40:17 -
Hey, man! Thanks for the input.
Nah, I actually originally pulled up another blank application and copied over all of the events from the engine by hand (typing out all of the equations and everything myself), and the only thing that references "timer" is that formula up there (and another formula just like it for another object).
However! While reading your comment, it suddenly hit me to create a counter and have it Always set to "timer". When I started the program, it just started counting up by what looked to be 1/1000ths of a second. So I guess "timer" is just that. Which, honestly, that knowledge doesn't really help me in figuring out what it's doing in this engine, haha.
If you'd like to check it out, I fully recommend it. This guy's made a lot of great engines: http://www.andersriggelsen.dk/mmf2_examples.php
n/a
|
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
|
29th April, 2011 at 13:17:24 -
timer is the time in milliseconds since the game has started (as it seems you might have worked out).
In that example he simply needs a way to continually change the "angle" used in the Sin functions. Since Sin(x) is a circular function, it doesn't matter where timer starts or ends. You could duplicate the same functionality by putting in "counter" wherever it says timer and then always add 1 to this counter. The "/24" is changing how quickly/slowly the "angle" increases.
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
|
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
|
29th April, 2011 at 13:22:53 -
I just opened his example then. He's superimposed 4 sine functions together to give the wave of the flag a less predictable motion.
To simply his code and make it more understandable, you can change:
velX( "Front" )+Abs((Sin(timer/24-LoopIndex("a")*10)*Sin(timer/41-LoopIndex("a")*10)+Sin(timer/15)*Sin(timer/19-LoopIndex("a")*10))*200) (twice - once for each object),
to simply:
velX( "Front" )+Abs((Sin(timer/24-LoopIndex("a")*10))*200)
and you will see one sinewave propogate through the flag.
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
|
Ando
Registered 08/04/2006
Points 100
|
29th April, 2011 at 14:54:59 -
Wow, thanks for that explanation!! It really helps a lot. I feel like I can jump back into it much more knowledgeably now.
Thanks again!
n/a
|
|
|