Trigger Common Event by Clicking on Player

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
556
First Language
English
Primarily Uses
RMMV
I want to trigger a common event when you click on the player character in RMMV.

Any thoughts on the most efficient way to do this?
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
Toss this into the conditional branch to check if the player character is being clicked on. I'm assuming you're using a 48x48 tile size.
Code:
Math.floor(TouchInput._x/48) === Math.floor($gamePlayer.screenX()/48) && Math.floor(TouchInput._y/48) === Math.floor($gamePlayer.screenY()/48)
Remember to do a script call to clear the clicked data after the event is over. Otherwise, your common event is going to loop.
Code:
TouchInput.clear()
BTW, nice resources you have there! I'm downloading them XD
 
Last edited:

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
556
First Language
English
Primarily Uses
RMMV
Awesome! Thanks so much. That script works perfectly. Unfortunately, I have MouseSystemEx installed and it's causing it to activate on hover, so I'll have to find a workaround for that little hiccup. I'm going to have to do some tinkering to disable MouseSystemEx when I'm not in the menu. Thanks again!
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
Does it work if you add
Code:
Input.isPressed('ok')
to the condition? Hopefully this will place an extra check if the left mouse button is clicked.
 

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
556
First Language
English
Primarily Uses
RMMV
Not quite, but a separate condition check for TouchInput.isPressed() solved both the compatibility problem and a different problem (where it would trigger after moving to a clicked location). Thanks a ton for your help!
 

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,585
Latest member
Reversinator
Top