[Solved] Jump sound effect only while on ground

dipstick5000

  • Posts: 47
Hello, and welcome to my first post. I'm trying to make events for an actor so that when the jump button (enter) is pressed a sound will play. Since I don't have a double jump, I don't want the sound to play if jump is pressed while the actor is already in the air. I can't figure out how to do this, except with regions, so in my scene I have 5 regions on the “ground”. If the actor leaves the ground it also leaves one of the regions. So I tried setting up my block like this:

when enter is pressed
   if Self is inside Region
      Play Jumpsound

My problem is that I don't see how to choose certain regions. The choices are Self is inside Region, or Self is inside Last Created Region, or Choose Attribute. There are no attributes for my regions that I drew into my scene. With the block set up like this I get no jump sound. Take out the “if” and I get jump sounds while already in the air.

Am I going about this the wrong way? I'm new to Stencyl, so please forgive my ignorance. I imagine that there's some simple way to accomplish this, and I'm just not seeing it.

Thank you for reading my question.

« Last Edit: December 20, 2018, 10:24:38 pm by dipstick5000 »
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
PS: I also thought about having a region follow the actor and constantly redraw in new positions, but I don't know how I would keep it on the ground without using a whole bunch of processing power, since the actor is constantly moving. At least that way though, I could choose the "Last Created Region" option.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

Luyren

  • *
  • Posts: 2747
Image attached. The above blocks go in a collision event. No regions required.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

dipstick5000

  • Posts: 47
Luyren, thank you very much for the suggestions. I see a couple things I didn't know existed, like "if on ground". Sounds like exactly what I need. I'll try this a little later when I have some time. I actually did think of a collision event, but for some reason I dismissed it. I feel bad for my lack of knowledge and wasting your time. I thought I'd done enough tutorials, practicing, and research to earn the right to post this question, but maybe not.

I also thought of something while I was sleeping last night. I assume I can record the y position of the actor as soon as jump is pressed, then deactivate the sound when the actor is not at that y position. Anyway, this is an enjoyable learning process, and I will definitely try your suggestion first.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
By the way, how do I choose specific regions when the only choices are "region" and "last created region"? Shouldn't there be a "choose region" option? (Not for this issue, but for my learning in general.)
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
Oh man people, I am so sorry. It's so simple and obvious, as I expected. I should have done more research and practice. There is no option to choose specific regions in actor events, but there is in scene events.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

Luyren

  • *
  • Posts: 2747
For the record: On Ground and Touching Ground in the image I posted are two boolean attributes, you have to create them in your behavior.

As for choose region (or choose actor when applicable), you can only do that on scenes. So either in a scene event, as you found out, or if you turn on instance customization for your actor: place it in a scene, double click it, go to the inspector tab on the right and check "Customize". You can then find your behavior and select a region on the scene.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

dipstick5000

  • Posts: 47
For the record: On Ground and Touching Ground in the image I posted are two boolean attributes, you have to create them in your behavior.

Ah yes. I get it. Thanks again.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
Update:
I tried for several hours to do it the right way. I was almost successful several times, but just when I thought I was going to get it, parts of my blocks would turn red (meaning "this ain't going to work"). I'm sure the problem is my inexperience rather than bad advice. Anyways, I finally gave up and went with using regions. It works perfectly. The only problem I can see that in huge scenes there would be many regions. For what I'm doing now though, it's fine. It looks like this:
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.

dipstick5000

  • Posts: 47
Just in case anyone is interested:

I figured out a much more simple solution than regions or collisions. I got to thinking that I would end up using way too many regions if I went with my previous solution, and I couldn't quite get collisions working, so I started thinking about actor Y speed. Here's what I came up with (it works great):

("On Ground" is a boolean game attribute)

When Scene is drawn
   If Y speed of Actor = 0
      Set On Ground to True

When Scene is updated
   If On Ground = True
      If Enter is pressed
         Play sound
         Set On Ground to False

Real simple. Still, thank you very much Luyren.
Tonight I'll make a game like Skyrim or Call of Duty. It'll be called Delusional.