Randomize SE in moving route

Kuu_t

Veteran
Veteran
Joined
Jun 19, 2016
Messages
30
Reaction score
20
First Language
Finnish
Primarily Uses
RMMV
Hello everybody,

I have a traditional puzzle, where the player pushes a boulder on the button to open a door.

The puzzle is fine, but I'd like to do it more interesting for the player. I'd like to randomize the pitch of the pushing SFX to make it less monotonous to listen.

Is there a way to achieve this by eventing? I prefer eventing over a plugin because I'm already using Yanflies moving route plugins. I'm afraid that I'd broke the system with another plugin to override the moving route.

 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,270
Reaction score
1,372
First Language
English
Primarily Uses
RMMV
Set a variable to random value (for example, random 1-3), then make conditional branches to cover each possible outcome (1, 2, 3, if following the example) with a different sound.
 

Kuu_t

Veteran
Veteran
Joined
Jun 19, 2016
Messages
30
Reaction score
20
First Language
Finnish
Primarily Uses
RMMV
Thanks! Unfortunately, I had to do it outside of the moving route loop. This is a bit clunky solution, but it works.

 

OS87

Warper
Member
Joined
May 11, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hey,
I wrote a little script for you to handle randomized sound effects within a move route.

add it to a new .js file in your js/plugins folder and activate it in the editor.

Code:
function soundPool(a, b) {
    // a = sound file name
    // b = number of sounds
return a + Math.floor(Math.random() * (b+1));
};
To use:
Create copies or rename your sound files so they share the same name, ending in a different number, starting at zero.
So the files would be:
Raise0.ogg
Raise1.ogg
Raise2.ogg

But it needs to start at 0, and there can't be any gaps in numbering. (so no 1,2,4,6).

In your Set Movement Route, select the "script" option, and paste in:
AudioManager.playSe({name: soundPool('Raise', 2), volume: 100, pitch: 100, pan: 0})

Obviously you can set the file name, the number to count up to, volume, pitch and pan to whatever you like!

How it works:
The script is a little function I've arbitrarily called soundPool, in the example above you give it two arguments: 'Raise' (the sound 'family' name) and 2; the highest number you have in that pool of sounds.
Used inside the AudioManager.playSe functionality from the engine itself, it justs chooses a random file from that pool of Raise sounds from 0 to the max you set.

Alternatively / Additionally:

Code:
function Pitchy(a, b) {
    // a = base value
    // b = range either side for random number
return a + Math.floor(Math.random() * (2*b+1) -b);
}
You can vary the pitch like this, input your base value and the number of variance you want on either side.

So in your setMovement you could have:
AudioManager.playSe({name: 'Raise0', volume: 100, pitch: Pitchy(100,2), pan: 0})

And this would use one sound, but every time it's played it'd be pitched within 2 of
100, (so it'd play at pitch 98,99,100,101 or 102).

You can use either or both at the same time, and they won't interfere with any other scripts, they're just additional tools you can use in your script calls.

Hope these help, your game looks nice!
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

The more I think about it, the weirdest part of going to work post-virus will probably be getting used to seeing my coworkers' mouths again. :LZYshock:
I think one of my weirdest realizations is that my speed of game development would probably be about the same if I *didn't* work a full-time manual labor job.
Quick question, what's the best way to capture-er, I mean RECRUIT playtesters? Should I make a project thread and use that?
Node Graph out of Date. Rebuilding...
Does anyone know of any good Discord groups for art or biology discussion, that sort of thing?

Forum statistics

Threads
98,056
Messages
948,945
Members
129,333
Latest member
rootcf
Top