SOLVED Problems with moves

Hi

I am making a. little app but I am having trouble with MoveTo The character is th
GML:
/// @description Insert description here
// You can write your code in this editor




//if mouse check is triggered then check against the
//Glob Wizard and run delete routine

if (mouse_check_button_released(mb_left))
{
    pos_x = mouse_x;
    pos_y = mouse_y;
    //if (position_meeting(x, y, ScatterIcons))
    //{
            
    //}   
    
    //if (position_meeting(x, y, ScatterIcons))
    //{
        ///if flight == true
        //{
            if point_distance(x, y, pos_x, pos_y) > 5 //flight is equal to true
            {
                move_towards_point(pos_x, pos_y,5);
        //        flight = false;
            }
            else
            {
            
            
                    speed = 0;
                    //at location
                    if x <= 0
                    {
                        x = 0;
                    }
                    if (y <= 0)
                    {
                        y = 0;
                    }
                    if (x > 1600)
                    {
                        x = 1600;
                    }
                    if (y > 1600)
                    {
                        y = 1600;
                    }
                
                
            }
        //}
    //
    //}
    
    
    if (x < 0 || y < 0 || x > 1000 || y > 1000)
    {
        show_debug_message("ScatterIcons.x");
        pos_x = mouse_x
        pos_y = mouse_y
        flight = true
        if point_distance(x, y, pos_x, pos_y) > 5 //flight is equal to true
        {
            move_towards_point(pos_x, pos_y, 5)
            flight = false;

        }
        else
        {
            //speed = 0;
            //flight = true
        }
    
    }



}
e GobbleWizard. You supposed to click on a spot
on the background and the GobblerWizard moves to that point and it sits now. What is happening is it moves to the target l location but then
keep movement in that direction. I even do the function to check distances and it seems it is not effective. Code below:


Step Event:
 

Nidoking

Member
I see a lot of checks that are only happening during the step when you release the mouse button, and no checks happening at any other time. Gotta watch how those curly braces are grouped.
 
for neater code, you can use min, max and clamp, like
GML:
x = clamp(x, 0, 1600);
And as for stopping, you will need to tell it to stop, because move_towards_point doesn't do it automatically once it reaches the specified point. You have to make the checks separately.
You commented out the part where it tells to stop. It's literally the example from the manual.
 
Top