Status
Not open for further replies.

Sc0wly

Veteran
Veteran
Joined
Feb 13, 2017
Messages
46
Reaction score
12
First Language
English
Primarily Uses
RMMV
Hello all! I was just wondering if anyone knows of a way to craft a parallel event that causes the player character (on the overworld) to always turn toward the cursor. Either that or turn the player toward the current cursor position on click. Thank you for any help you can provide.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,183
Reaction score
10,819
First Language
Czech
Primarily Uses
RMMV
Search for how mouse x and y are handled inside rpg_core.js. Then the event will have this one script command:
Code:
var x = $gamePlayer.screenX() - the mouse x;
var y = $gamePlayer.screenY() - the mouse y;
Then:
if (Math.abs (x) >= Math.abs(y)) x > 0 ? $gamePlayer._direction = 6 : $gamePlayer._direction = 4;
else y > 0 ? $gamePlayer._direction = 8 : $gamePlayer._direction = 2;

I would have helped more precisely, but right now I don't have a computer, so cannot construct the precise script.
 

Sc0wly

Veteran
Veteran
Joined
Feb 13, 2017
Messages
46
Reaction score
12
First Language
English
Primarily Uses
RMMV
Thanks, Poryg. Not sure if I'll have much luck, but I'll look into it. :)
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,183
Reaction score
10,819
First Language
Czech
Primarily Uses
RMMV
Sure thing. The mouse is called TouchInput and the methods should contain pageToCanvasX and pageToCanvasY if I remember correctly.
 

Sc0wly

Veteran
Veteran
Joined
Feb 13, 2017
Messages
46
Reaction score
12
First Language
English
Primarily Uses
RMMV
So I'm not having much luck. I can't write a script myself (don't currently have the knowledge). What I am able to do is create parallel events which define the player's xy (grid) coordinates as variables which can be used for various things. I've also defined the mouse cursor's xy (pixel) coordinates as variables, which is extremely useful for many game mechanics that I'm not currently using. I could explore some more possibilities if I knew how to store the cursor's xy grid coordinates in variables. Then I could attempt to make a conditional branch that compares player grid position that that of the mouse cursor and reacts accordingly. No luck so far though :/
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,183
Reaction score
10,819
First Language
Czech
Primarily Uses
RMMV
You can't do mouse grid coordinates, but you can do player screen coordinates.
 

Sc0wly

Veteran
Veteran
Joined
Feb 13, 2017
Messages
46
Reaction score
12
First Language
English
Primarily Uses
RMMV
Ah, nice. I was able to do what you recommended. I'll have to experiment a bit more to see if I can use these variables in the way I described earlier and whether the behavior looks correct on screen. I'm hopeful now though. Thanks for the advice, Poryg! :D
 

OgreLeg

Veteran
Veteran
Joined
Nov 23, 2017
Messages
42
Reaction score
3
First Language
English
Primarily Uses
RMMV
So did this work? I've been scouring the net for 7 hours on how to do this and this post is the closest I've come. Face direction of mouse cursor or face direction of mouse click. I've tried doing it a few different ways by getting the X/Y of both player and touch input but I can't seem to get it right.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,715
Reaction score
6,169
First Language
Dutch
Primarily Uses
RMXP

OgreLeg, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.



Closing this.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

ScreenShot_6_28_2022_3_2_40.png

There's 7 main areas in the game that are all connected. This train get's you from an underground lab to the center of someone's subconscious. inside the train you can talk to some of the passengers. but going to the top of it, there's battles.
Speedrunning all character portraits just so they all have the same quality. Not sure if this was a good idea, but now I'm almost done.
We now have a gameplay video!
DrBuni wrote on Akiritas's profile.
That is a cute Link picture, reminds me of the Samurai Jack artstyle.
I had an idea on how to get my encounters to leash after chasing the player for a little bit. After going down the Javascript rabbit hole, I realized I could do it in a regular movement route. Derp!

Forum statistics

Threads
123,146
Messages
1,154,378
Members
161,492
Latest member
moslngs
Top