Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Terrain Style Features

boon

Sponsor

I need a way so I can set all snowlike tiles so that when the hero walks on them it makes a crunch, but when he moves onto path there is no crunch.

Is there a way to do this? I need it for terrains like grass and bridges and such.
 
Yep... the way I do it is make a common event with a conditional branch checking the players terrain tag, then if it returns the one you want I have if left key is being pressed = play SFX wait 8 frames.  Then do that for all directions.  Remember to set the variable initially to check for the players terrain ID.

Only downside is - if the player is on grass right next to a wall and you hold towards the wall ,the player wont move but the sound effect continues as the left button is being pressed etc.
 
That is for one sound effect.  If you wanted to change it, it stills require the same eventing to check the terrain tag so it's nearly just as much work but essentially less customisable.
 

boon

Sponsor

Calibre":wmblzb3v said:
Yep... the way I do it is make a common event with a conditional branch checking the players terrain tag, then if it returns the one you want I have if left key is being pressed = play SFX wait 8 frames.  Then do that for all directions.  Remember to set the variable initially to check for the players terrain ID.

Only downside is - if the player is on grass right next to a wall and you hold towards the wall ,the player wont move but the sound effect continues as the left button is being pressed etc.
]

How do you do that, terrain isn't listed under conditional branches (xp)
 
variable operations, have it as set... go down to player and on the pull down menu put it as terrain tag.  That means when the game checks the numerical value of the variable you just set,it returns the number that you have assigned to that terrain in the tilesets properties.

In simple terms just in case:

YOU: So rpgmaker, what is the numerical value of Variable 001

RMXP: Well my fellow maker, the player is standing on grass... in the editor you set all grass to terrain tag 1 so the value of Variable 001 is currently 1.

YOU: Ahh... but what about if I move my player over onto this gravel...

RMXP: You know the answer! Check in your tilset's properties...

YOU: Okay it seems i set gravel to have a number 4 for it's terrain tag... so I guess the variable mustcurrently be returning 4...

RMXP: Yeah... that is right, that's why it is called a variable, because it can change values!

YOU: Thanks RPG MAKER XP, you are by best friend!

RMXP: Get out the house and go for a walk.
 
It's much easier to do this with scripts. Here's a really simple way to do it:
Go into the script editor and choose Game_Player. Press Control-F (for find) and type "super" then paste this line right above "super"
Code:
Audio.se_play("Audio/SE/SOUNDEFFECT" , 80, 100) if $game_map.terrain_tag(new_x,new_y) == TERRAINTAG and $game_map.passable?(new_x, new_y, d, self)
replace SOUNDEFFECT with the name of the sound you want to use and TERRAINTAG with the terrain ID you want to use (e.g. 5).

you can add the same line with a different sound effect/terrain type for multiple different effects (grass, snow, whatever)

Note: If you have a heavily modified Game_Player script, just make sure that the super you paste it above is in the "def passable?(x, y, d)" block.
 
Well if that works cool but doesnt that seem like the sound effect would just repeat continuously - it needs a delay to simulate the walking, on speed 4 8 frames is the perfect delay between steps.  I just prefer events because I know that I can alter  them without help.
 
No it shouldn't repeat infinitely.  I have had this system working for years, it is pretty simple. Are you sure you have added the wait 8 frames after each sound effect that is played?
 

boon

Sponsor

I put this, as a common event:

<> Conditional Branch: Variable [014: terrain] == 1
  <>Play SE: "grassswish1" 80, 70
  <>Wait: 8 frames
  <>Stop SE
: Else Handler
  <>
: End
<>
 
Yep that is wrong.

You need to have it quite a bit longer and inside that terrain check you need to add four more conditional branches for player is pressing left, right, up and down.  That means you have to be moving for the sound effect to play.

If you still can't get it to work after that seeing as you have been polite I'll sort it out for you.
 

boon

Sponsor

Okay, thank you very much.

The Key press was something I was using in my old sytem , edges of the grass turned on/off the switch that activated it.

Thanks again, this will really help my game.
 
Calibre":2rnwz3cj said:
variable operations, have it as set... go down to player and on the pull down menu put it as terrain tag.  That means when the game checks the numerical value of the variable you just set,it returns the number that you have assigned to that terrain in the tilesets properties.

In simple terms just in case:

YOU: So rpgmaker, what is the numerical value of Variable 001

RMXP: Well my fellow maker, the player is standing on grass... in the editor you set all grass to terrain tag 1 so the value of Variable 001 is currently 1.

YOU: Ahh... but what about if I move my player over onto this gravel...

RMXP: You know the answer! Check in your tilset's properties...

YOU: Okay it seems i set gravel to have a number 4 for it's terrain tag... so I guess the variable mustcurrently be returning 4...

RMXP: Yeah... that is right, that's why it is called a variable, because it can change values!

YOU: Thanks RPG MAKER XP, you are by best friend!

RMXP: Get out the house and go for a walk.
Haha, this post is made of win :P
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top