Navigation Control Override for Docking

As my game has gotten more complicated I have been posting less on this forum because of how difficult it is to explain my problems. However, I think someone might be able to help me with this and I can explain it easily.
I have a navigation system in the step event that is making the ship's angle point towards the mouse.
And in a key pressed event for the letter "T" I have a code that I believe will make the ship move towards the coordinates I have coded as the docking point.
But the navigation controls are overriding this docking code...because they are on the step event.
But how do I make it so that when the "T" button these navigation controls are overridden?

Create Event:

global.isDockedx = obj_base.x + 145;
global.isDockedy = obj_base.y + 0;

Key Pressed "T":

image_angle = !point_direction(x, y, mouse_x, mouse_y);
if point_distance(x, y, obj_base.x, obj_base.y) <250{
move_towards_point(global.isDockedx, global.isDockedy, 1);
image_angle = obj_base.direction;

if point_distance(x, y, global.isDockedx, global.isDockedy) <5{
speed = 0;
}
}
if point_distance(x, y, global.isDockedx, global.isDockedy) <= 0{
friction = 5;
}
 

Nidoking

Member
image_angle = !point_direction(x, y, mouse_x, mouse_y);
Did you mean to set the image_angle to a boolean value?

Generally, if you want an object to exhibit different behavior under certain conditions, you will need some sort of state logic. You can either manage a persistent state for different activities (recommended) or just set something to true when you press T and false when it reaches the dock, and don't do the other normal movement while that variable is true.
 

woods

Member
i would go something along the lines of..

create
Code:
is_docking = false;
step
Code:
if (keyboard_check(ord("T")))
{
is_docking = !is_docking;
}
step
Code:
if (is_docking = true)
{
//things you want done while "T" is held down
is_docking = false;
}
else
{
//normal controls
}
 
Top