1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

[SOLVED]Sprite shakes

Discussion in 'Programming' started by Phemus, Oct 8, 2016.

  1. Phemus

    Phemus Member

    Joined:
    Jul 31, 2016
    Posts:
    90
    I wanted to make object follos object. But when I stop to moving the player and object come and stop, it starts to shaking. My code is;

    move_towards_point(parent_player.x-30,parent_player.y-30,3);

    Thank you.
     
  2. CoderJoe

    CoderJoe Member

    Joined:
    Jun 22, 2016
    Posts:
    166
    Not clear on what is shaking: the player or the object following the player? One quick idea is to put the code in the end step event.
     
  3. Phemus

    Phemus Member

    Joined:
    Jul 31, 2016
    Posts:
    90
    The objects starting to shaking when it comes to target area.
     
  4. CoderJoe

    CoderJoe Member

    Joined:
    Jun 22, 2016
    Posts:
    166
    Ok. This is probably because the object moves to the target area but overshoots it a little (check the speed it is moving at). It then trys to correct itself and goes the other way creating that shaking effect. I would add some sort of check so that it only move when it is within a couple pixels of the target area. Simply get the distance between the objects and check if it is less than a certain amount.
     
  5. DariusWolfe

    DariusWolfe Member

    Joined:
    Sep 23, 2016
    Posts:
    32
    I've had the same problem; I knew the cause, but didn't want to take the time immediately to solve the problem. I haven't implemented it yet, but riffing off of CoderJoe, it seems to me that if you do a distance check, and if it's below a certain threshold, assign x and y to the desired values, instead of using the move_toward_point() function.
     
  6. Phemus

    Phemus Member

    Joined:
    Jul 31, 2016
    Posts:
    90
    Okay. I've solved the problem with using this script:

    if distance_to_object(obj_one)>10
    {
    move_towards_point(obj_two.x-30, obj_two.y-30,3)
    }
    else
    {
    speed = 0;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice