• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Visual Virtual key as a trigger for NPC

I

id07

Guest
So I'm trying make a basic RPG room for testing.
And I wanted to have a virtual mouse click/button (for android) that when colliding with an the object (NPC) , that upon clicking the visible virtual key/a button (mouse left click) in the room, the collision would check that the left button is pressed and in the NPC object, will do things, like dialogue

So I have 3 objects that I want to use

the NPC
the player
the virtual A button (left mouse pressed)

In the NPC object -
I have it set up with
a collision event with the player obj
and have this code:

Code is set to "a_button_active_obj" and not self
-----------------------------
if instance_exists(a_button_active_obj)
{
if mouse_check_button_pressed(mb_left)
{
show_message("Hello!");
}
}

--------------------------------------------

In the player object there is nothing.

Nothing in the A button object

I have set up arrows that represent movement as a virtual d-pad on screen and are set to "left button pressed" (depending on the direction) for continuous movement when holding down the virtual key.
Now when the player does collide with the object, because the virtual d-pad uses the mouse click, once I collide with the NPC, if the virtual key is not pressed, but rather clicked next to the object, it brings up the hello message. But, I'd like a virtual button (an A button) to trigger the dialogue instead of using the d-pad, which the A button doesnt work at all. SO it all works, kinda, but I want to use the virtual a button as a trigger.

Any suggestions or advice how to better achieve this? Thanks in advance!
 
T

TheTrophieStars

Guest
I'm not sure if I fully understand your dilemma, but maybe "disabling" your virtual d-pad when near an npc will keep you still while talking to them. You could use an alarm to turn the virtual d-pad back on. If you could try explaining your issue more clearly, maybe I could help more.
 
I

id07

Guest
Well, to put it simply:
I have a player obj, an npc object, and a virtual A button that represents the left button of the mouse.
I'd like to put a collision event on the NPC, that when the player collides with the NPC object, pressing the A button object (the virtual mouse button) will activate whatever code is attached to the NPC object.

So, on screen there is the player, the NPC, the virtual d-pad, and the A button.

What I would like to happen, is:
The player moves towards the NPC using the dpad, and then the player can press the A button on screen, which brings up the hello.

Because the virtual Dpad uses "pressed" for movement, when the player does collide with the NPC, if the player does a quick click on the dpad again, it triggers the Hello - I want this to be for the A button object.

Does that make better sense?
Regardless, thanks for the reply :)
 
I

id07

Guest
I still haven't figured out the original post yet, but rather then start another thread so quickly after this one: any advice/help with deleting an object/instance in a different room ?

Scenario:
Player is in one room and an object exist, but goes to another room(a specified room), clicks on an object, then they go back to whatever the previous room might have been and the object gone.

In other words, what is the reverse of this:
room_instance_add

Thanks for any help!
 
Top