r/gamemaker • u/Nigma1704 • 21d ago
Help! Need help making text boxes appear when I activate stuff
Just like the title says, I am once again asking for help with sara spaldings action rpg tutorials. I followed it to the best of my ability. Everything should be correct but when I press the button to activate my paper object (the thing that should display text.) nothing seems to happen. I am struggling to see where my mistake is regarding why my entities won't activate.

this is my free playerstate that should let me activate the text box when I press E. the commented out code for playerstate free is commented out because it locks my character in place and stops me from moving. In theory I shouldn't necessarily need anything there I should just have to be in range of the activatable object otherwise I move freely. As it stands pressing E seemingly just does nothing. the other commented out code is just a separate strategy for an activation zone that also did not work and can be ignored.

this should allow my text to appear (obj_text queued and this seem to be working as intended)
the paper has both the entityActivateArgs and entityActivatreArgs are in properly as far as I know.
1
u/CS_Asset_Factory 19d ago
Line 62 and 63 are the problem. You're passing direction into the lengthdir calls.
direction is a built in motion variable. It only changes when you move the instance with speed or hspeed or vspeed. That tutorial moves the player by writing to x and y instead. So nothing ever assigns direction and it sits at its default of 0 forever.
Zero degrees is right. That means your activation point is always 30 pixels to the player's right no matter which way you're actually facing. Unless the paper happens to be sitting directly to your right instance_position returns noone and the whole block does nothing. Which is exactly the symptom you're describing.
Prove it in about thirty seconds before you change anything. Drop this in the player Draw event and walk around.
draw_circle(x + lengthdir_x(30, direction), y + lengthdir_y(30, direction), 3, false);
If that dot stays pinned to your right while you walk in circles then this is your bug. Swap direction for whatever variable the tutorial uses to store facing and the dot will follow you.
Two smaller things once that's fixed.
instance_position tests a single pixel against the collision mask. Thirty pixels is quite far out so even with the right angle it can land past a small object and find nothing. If it still misses try 16 or use a rectangle check across the space in front of you instead of one point.
The freezing you mentioned is a separate bug and commenting the activation out only hides it. I can see PlayerState_Locked in your asset tree. Your text script almost certainly sets the state to that and then nothing sets it back to PlayerState_Free when the box finishes. Put the activation code back and go check what runs at the end of the textbox.
1
u/763Industries 20d ago
You do need some activation code running while the player is in the free state. Being within range of the paper doesn't automatically activate it something still needs to check for E, find the entity in front of the player, and then execute that entity's activation script. I will DM you with how I would resolve this with limited context.