Trying to read directional movement

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Hi everyone, I was working on this tutorial, However, as the tutorial explains, I have a variable for player direction (2,6,8,4) for Down, Right, Up and Left. So I have conditional branches that shoot projectiles in the given direction based on that variable.

Pretty simple, but I was hoping 9,7,1, and 3 would work as diagonal, but they don't seem to. So I tried a branch that checks for up AND Right and it still didn't seem to work.

Surely there's an easy way to do this, or a chunk of script. Thanks!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Tutorials is where people who have written a tutorial for others to use can post it.

[MOVE]RPG Maker MV[/MOVE]
If this requires a plugin, please Report this post and ask for the thread to be moved to JS Plugin Requests.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Diagonal movement is only possible in MV with a plugin.

If you HAVE a plugin that allows diagonal movement, then it would also have a way to detect that the player is facing in a diagonal direction. But we would have to know what that plugin is, in order to tell you how to check for that.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Tutorials is where people who have written a tutorial for others to use can post it.

[MOVE]RPG Maker MV[/MOVE]
If this requires a plugin, please Report this post and ask for the thread to be moved to JS Plugin Requests.
Appreciate the help, thanks.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Diagonal movement is only possible in MV with a plugin.

If you HAVE a plugin that allows diagonal movement, then it would also have a way to detect that the player is facing in a diagonal direction. But we would have to know what that plugin is, in order to tell you how to check for that.
Ah, makes sense. I am using GALVs diagonal movement.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Got a link so I don't have to go searching for it?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Okay - you didn't actually say how you're getting the direction into the variable. But with that script enabled, you should be able to do
Control Variables: YourVariable = Script: $gamePlayer.getInputDirection();
which should return the original 4 straight directions, as well as 1, 3, 7 and 9 for the diagonal directions.

If you can't get this to work, please show a screenshot of your plugin manager, and a screenshot of your event where you're trying to check the direction.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Okay - you didn't actually say how you're getting the direction into the variable. But with that script enabled, you should be able to do
Control Variables: YourVariable = Script: $gamePlayer.getInputDirection();
which should return the original 4 straight directions, as well as 1, 3, 7 and 9 for the diagonal directions.

If you can't get this to work, please show a screenshot of your plugin manager, and a screenshot of your event where you're trying to check the direction.
Hey, thanks again. I tried it out, but it seems to bring up some issues that I can't really explain. My screenshot here shows how I get my Player Direction, and my conditional branches using them. Essentially what I want to do is fire projectiles on an angle.

What I used to use was Galvs Map Projectiles, which was really great because I could simply fire my projectiles at Mouse position, which is essentially what I'm hoping to do. However, that plugin isn't quite working with all the other ways I've decided to manage my gameplay, so I've stopped using it since.
 

Attachments

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
So you can't use that kind of conditional branch, because it only caters for the 4 directions. You'd have to use a script call instead. However, I realise what I gave you is the direction according to the keys pressed, but what you want is the actual facing direction even though keys may not be being pressed.

This is a directional movement plugin, not an 8dir sprite plugin, so there must be another you have for that.

Try something like this ...
Code:
Control Variables 50 Player Direction = Script: $gamePlayer._diagDir > 0 ? $gamePlayer._diagDir : $gamePlayer.direction()
If the above doesn't work, please give a link to the plugin you're using for the 8dir sprites, as we'll be able to check to see which row of the spritesheet is active, and that will give the direction.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
So you can't use that kind of conditional branch, because it only caters for the 4 directions. You'd have to use a script call instead. However, I realise what I gave you is the direction according to the keys pressed, but what you want is the actual facing direction even though keys may not be being pressed.

This is a directional movement plugin, not an 8dir sprite plugin, so there must be another you have for that.

Try something like this ...
Code:
Control Variables 50 Player Direction = Script: $gamePlayer._diagDir > 0 ? $gamePlayer._diagDir : $gamePlayer.direction()
If the above doesn't work, please give a link to the plugin you're using for the 8dir sprites, as we'll be able to check to see which row of the spritesheet is active, and that will give the direction.
Yeah, the MapProjectiles shoots on diagonals too. But GALVS diagonal has an option to use diagonal sprites. I'm not so concerned about the gamePlayer using a diagonal sprite, I'm trying to shoot my projectile (another event) diagonally. If you check out the video I linked at the top real quick, it shows him shooting a chicken, I essentially used this method as reference, but instead of just the 4 directions, I'd like to shoot at least 8. However, what I'm really working towards is firing towards mouse position. Which is a whole new ballgame lol.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Did you try the code above? What happened?
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Script: $gamePlayer._diagDir > 0 ? $gamePlayer._diagDir : $gamePlayer.direction()
Seems to do the exact same thing as what I'm working with. Shoots in the 4 directions.
Edit: I have to fool around with it more, once I started walking on an angle I realized that I think it's actually working, but I have no conditions set up for it. I'll let you know.
Edit#2: I set up conditions and it seems to work. The only downfall is that it only works while moving directional, so if I'm still (against an object in which I can move) then it's shooting either up or straight ahead. This is pretty cool though. Ideally I'd like to set up a button press to stand still if I did it this way, like in Diablo when you press "Shift" and you can stand still and shoot projectiles. Thanks for all your help!
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,583
Latest member
write2dgray
Top