Hi,
I have yet another question for anyone. When an animation is playing, and the current frame in the animation equals, say, 5, how might I make TGF play a random sample out of the sample library? Is that possible?
Thanks very much
Printable View
Hi,
I have yet another question for anyone. When an animation is playing, and the current frame in the animation equals, say, 5, how might I make TGF play a random sample out of the sample library? Is that possible?
Thanks very much
You can do this through the "Play sample from a file..." action, though I don't think that you can do it with samples stored in the game itself. The crucial thing is that this action allows you to put in an expression - so you can either name your samples sequentially and add a random number (random(n)) to the end, or pick a random entry from a list containing all the possible filenames.
I think I understand what you mean. But could I trouble you to give step by step instructions? Let's say I have the samples called o1,o2,o3, and they're all in a folder "samples". The animation that will be playing is "anim". Also, I'd like the sample to play every time the frame in the animation is at 15. Using these variables, would you mind explaining it step by step? Thank you kindly.
OK - with the variables you provided, the whole thing can be done in one event:
+ Object animation "anim" is playing
+ Frame of Object == 15
+ Only one action when event loops
-> Play sample file on a specific channel > Expression:
File: "./samples/o" + Str$(random(3) + 1)
Channel: Anything from 1-32
I like your amount of explanation, by the way - things are so much easier to answer when they're like this!
I appreciate the explanation, though I got stuck on this part:
-> Play sample file on a specific channel > Expression:
File: "./samples/o" + Str$(random(3) + 1)
Channel: Anything from 1-32
so I click "Play sample file on a specific channel". Then it asks me to browse for a file. I have all of my "o" file (like 01, o2, ect) in one folder. Do I then just choose one of the "o.wav"s?
I'm also not sure what you meant by " File: ./samples/o" + Str$(random(3) + 1)". is the "./samples/o" referring to the full path for the files? Like should I put 'C:/Documents and Settings.../o.wav"?
I tried putting in "File: "./sounds/o" + Str$(random(3) + 1)" in the Expression, but it wouldn't allow it.
Sorry to be a burden, I've just never dealt with this before. Just talk to me like I'm a monkey and I might understand :)
I'm just guessing, but try taking the full stop from the beginning of the filename:
"/sounds/o" + Str$(random(3) + 1)"
Removing the full stop will make the application look in your root directory - the . is there to indicate that the path should start in the folder that the application is running from.
When you're prompted to choose a file after selecting the "Play sample file" action, choose "Expression" on the file selector instead and you'll be given an expression editor - this is where the ""./samples/o" + Str$(random(3) + 1)" should go.
The expression builds up a filename piece by piece. The (Str$(random(3) + 1)) selects a random number between 1 and 3, and converts it to a String instead of a value so that it can be added to other Strings. (The random(n) expression picks a random number between 0 and n-1).
After that, we add "./sounds/o" to the start of it - this gives the file name "./sounds/oX", where X is a random number from 1 to 3.
Now that I look at it, I got the expression wrong the first time, as it needs a .wav on the end as well. So the complete expression you enter for the file should be:
"./samples/o" + Str$(random(3) + 1) + ".wav"
This will take a random sample from o1.wav, o2.wav and o3.wav from the folder (Where your application is stored)/samples/.
My bad David, I assumed it would start from where the app was and go from there. Something else I've learnt, thank you :)
Something I forgot to mention- I'm using the Demo version of TGF, which I thought had all the same features as the registered one (except being able to build a stand-alone app.
Ok, so when I get to the part I'm stuck at- I right click on the sound column in the event editor, and then click on "play sample on a specific channel" (I've also tried clicking "Play Sample"). But there is no "Expressions" option. I don't see "Expressions" anywhere, it only lets me either choose sample from file, or from another application.
You have to use "Play Sample File on a Specific Channel". That has an expression option.Quote:
Originally Posted by mussashimits
I'm sorry, but I don't see an expression option. And I am using TGF 2 demo version. I only see the options to Browse for samples "From another File" or "From an application." Yet when I browse and click on one of the samples, I get an expression window that says "Channel number (1...32)" at the top, and it says "Enter Expression to calculate". Is that what you're talking about? I assume not since I have to actually open a sample first.
"Play Sample File on a Specific Channel" is an action that I have in MMF2 Developer under the sound object. I don't know if it is in TGF2 or in the TGF2 demo.
alright, I think I got it! Just needed to use MMF instead of TGF.. I wonder what the real difference is anyway. MMF also seems to run a tad slower, or maybe it's just my imagination. Anyway, thank you to all who helped me.