KyleRansford
Member
This question might seem a little too obvious but, I'm using a point_in_rectangle(); to check for collision when the player walks up to an NPC to start a dialog with. The problem is, the player can only activate the dialog when they are above the NPC. This is on a 4-way movement style game by the way. The player can't activate the dialog when they're on the left, right or bottom of the NPC.
What I'm trying to do is, draw exactly where the point_in_rectangle is so I can adjust it. But when I try to draw it using draw_rectangle(); it doesn't line up with the point_in_rectangle();
How can I do this?
Here are the coordinates and some code:
and here is the Step Event calling the code portion. (There is a ton more code by the way)
I've also tried other collision and point methods but they don't seem to work or they activate the dialog of an NPC near the other side of the room.
What I'm trying to do is, draw exactly where the point_in_rectangle is so I can adjust it. But when I try to draw it using draw_rectangle(); it doesn't line up with the point_in_rectangle();
How can I do this?
Here are the coordinates and some code:
Code:
point_in_rectangle(o_player.x, o_player.y-10, o_player.x-15, o_player.y-28, o_player.x+15, o_player.y+28)
Code:
if !instance_exists(o_player) {
exit;
}
var dr = detection_radius;
if(point_in_rectangle(o_player.x, o_player.y, o_player.x-20, o_player.y-20, o_player.x+20, o_player.y+20)) {
if(myTextbox != noone){
if(!instance_exists(myTextbox)){ myTextbox = noone; exit; }
}
//if I haven't already created my textbox, make one:
else if(o_input.action_four_pressed_){
if(instance_exists(obj_textbox)){ exit; } //exit if a textbox already exists
event_user(0); //if you need variables to update for text
//Hand over variables
create_dialogue(myText, mySpeaker, myEffects, myTextSpeed, myTypes, myNextLine, myScripts, myTextCol, myEmotion, myEmote);
}
} else { //if player moves outside of detection radius
if(myTextbox != noone){
with(myTextbox) instance_destroy();
myTextbox = noone;
}
}