Pushable events still making sounds even when they can no longer move.

Whenever the player moves a rock a rolling sound effect plays. However when it can no longer be pushed forward, the rolling sound continues to play every time I interact with the rock. I don't want the rock to make any sound when it's stuck.

This is the movement route I set for the rocks but it doesn't work...

rockkkk.png
You'll need to use a conditional branch with a script as condition:
JavaScript:
this.canPass(this._x, this._y, $gamePlayer._direction)

Inside the branch, play the sound. You can also use the Else branch for a different sound (for example a sound for when the rock collides with something).
Here's a solution without any need for plugins or scripting!
In the corner, create an invisible (through) event on a parallel process.

In the parallel event, create 2 new variables.
Rock X, Rock Y.

Next, go to Control Variables, and make it to where Rock X is set to Map X of the Rock event.
Do the same thing for Rock Y, setting it to Map Y of the same Rock event.

You have now created a process where the game is constantly checking the X and Y coordinates of that rock event.

Next, in that parallel process, beneath all of that, create a conditional branch, and set it to where:

If Rock X{ (X value in your game)
{ If Rock Y= (Y value in your game)}
{Switch ON}


(You'll need to also make a Switch on that rock event to where that rock event just remains there without any kind of interactivity).



I used this tactic a lot to make coordinates match in my game. It's very helpful, and can be used in many instances! Try playing with it.
@PoptartPresident There's an easier way to get coordinate info that doesn't involve a parallel process.

1644290810750.png


The 'Get Location Info' event command is the key you need, and can be put right in the event itself. See the following boulder event from a prior build of my game:

1644290925001.png
@PoptartPresident There's an easier way to get coordinate info that doesn't involve a parallel process.

View attachment 215621

The 'Get Location Info' event command is the key you need, and can be put right in the event itself. See the following boulder event from a prior build of my game:

View attachment 215623

Ah yes! This works as well.
Wow! thanks a lot, guys. Problem solved.

I tested these solutions and I ended up using the script one. However, the script didn't work at first so I had to use a very similar script, one posted by the blue squirrel in another thread, and it works perfectly!

Now it's like this
For a script call approach I would personally use something like this instead:

var e = this.character(0); e.canPass(e.x, e.y, $gamePlayer.direction())
Differences:
  • Declares e locally (i.e. using var, let, or const) rather than globally. A local variable gets deleted after the script call is done.

  • Uses canPass to check for collisions with other characters as well as map tiles.
If everything's working, feel free to report your post with a reason like "Solved". A moderator will then come along to close the thread. 👋
For a script call approach I would personally use something like this instead:

var e = this.character(0); e.canPass(e.x, e.y, $gamePlayer.direction())

Differences:
  • Declares e locally (i.e. using var, let, or const) rather than globally. A local variable gets deleted after the script call is done.

  • Uses canPass to check for collisions with other characters as well as map tiles.
If everything's working, feel free to report your post with a reason like "Solved". A moderator will then come along to close the thread. 👋
Yes, it's much better this way! Now, when an event with this script collides with another event no sound is played.

Thank you!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/pushable-events-still-making-sounds-even-when-they-can-no-longer-move.144745/