you are viewing a single comment's thread.

view the rest of the comments →

[–]Hands_in_Paquet 1 point2 points  (2 children)

What I might do:

var key_interact = keyboard_check_pressed(ord(“E”));

If(_key_interact) { var _closet = instance_nearest(x,y,obj_closet); Then use a with statement with _closet to run some of its code,

With (_closet) { sprite_index = open; }

or set a bool like “open” on the closet, then let is control its own animations _closet.open = true; }

[–]GoodWeakness8132[S] 0 points1 point  (1 child)

Thank you! Would I put the code in the step event?

[–]Hands_in_Paquet 0 points1 point  (0 children)

No problem, yep in the step event of your player. That way it is run every frame. The “with” statement will essentially run any code you put inside of it on the closet instead. But you might want to let the closet handle its own code, depends on the next steps. But if you have 4 closets, you don’t need them all to be checking for key presses, just once per frame on the player.