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.

Checking Player Direction

In RMXP, I am trying to make a basic function for throwing items. I know how to do most of the script, but most of it relies on which direction the player character is facing. Is there a way of storing this in a variable in RGSS, and what would it return for each direction?
 
I wasn't asking how to print the direction, as that is kind of useless. I want to know how to store it in a variable, and obviously, I need to ask the system which direction it is facing.
 
Pretty easy, just do:
Code:
your_variable = $game_player.direction
Change "your_variable" for the variable you want to modify.
In case it is a game variable:
Code:
$game_variables[1] = $game_player.direction
And change "1" for the the id of the variable you want.

The returning values can be: 2, 4, 6 and 8, being:
2 = Down
4 = Left
6 = Right
8 = Up
Just like the directions in the Number Pad in the keyboards.
 

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