B
BoxFan
Guest
Hi,
I'm new to GameMaker and have run into an issue. I want the player to be able to interact with multiple objects like doors and signs with a single button. I figured the most efficient way to do this was to have the player character enter a state that the interactables would then respond to (like displaying a message or sending the player to another room). I've got it working about half-way.
I've got a really simple sign that I'm using as a guinea pig of sorts. When I walk up to the sign and hit space (which puts the player character into "state = true") it displays the message just fine. But if I've already hit space then the "state" still equals "true", and the sign still displays the message on collision.
Is there a way to bring the player character back to "state = false" to prevent this from happening?
Here's what I'm using to put the player into "state = true" (moose = true). It also prevents them from spamming the button because it plays a sound and I thought it was annoying when the sounds overlapped too much. There's also some placeholder animation in there.
And here's the code used to display the message from the sign.
Any help would be much appreciated
I'm new to GameMaker and have run into an issue. I want the player to be able to interact with multiple objects like doors and signs with a single button. I figured the most efficient way to do this was to have the player character enter a state that the interactables would then respond to (like displaying a message or sending the player to another room). I've got it working about half-way.
I've got a really simple sign that I'm using as a guinea pig of sorts. When I walk up to the sign and hit space (which puts the player character into "state = true") it displays the message just fine. But if I've already hit space then the "state" still equals "true", and the sign still displays the message on collision.
Is there a way to bring the player character back to "state = false" to prevent this from happening?
Here's what I'm using to put the player into "state = true" (moose = true). It also prevents them from spamming the button because it plays a sound and I thought it was annoying when the sounds overlapped too much. There's also some placeholder animation in there.
Code:
moosetime--;
if key_moose && moosetime < 0
{
moosetime = 15;
audio_play_sound(choose(sndMoose1, sndMoose2), 1, false);
moose = true;
moosetime--;
if moose == true
{
image_angle += (max(0, 180));
}
while moosetime < 0
{
moose = false;
}
}
Code:
if place_meeting(x, y, objMoose) && objMoose.moose = true
{
new_message = instance_create_depth(x, y, -999, objMessage);
objMessage.text = "HELLO!!";
}
if instance_exists(objMessage) && keyboard_check(vk_space)
{
instance_destroy(objMessage);
}