• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

We've got a problem about a moving character

N

nb2

Guest
Hello ! I'm doing with an amazing guy a pointn click game, and we've got a significant problem.
When we click in the right place where we want the character to go, he goes without problems, but when he stops, he starts shaking without stopping.
Moreover, when it enters in collision with an invisible object (express for the collision to stop) it stops correctly, but it is then blocked, we can no longer direct it anywhere.
Here the code :Capture.PNG

Would you have a solution, we'd really need one!
Thank you!
 

marasovec

Member
Your speed is 4 so the distance will probaby never will be equal to 1 because the player moves 4 pixels per step. This might work for you
Code:
if (point_distance(x, y, xx, yy) <= speed/2)
 

TheouAegis

Member
Code:
if point_distance(xx,yy,x,y)<speed 
{
    x=xx;
    y=yy;
    avancer=0;
}
else
if place_meeting(x-10,y,wall) 
{
    avancer=0;
}
speed=avancer*4;
direction=point_direction(x,y,xx,yy);
 
N

NeZvers

Guest
Code:
///move_to_point(x, y, xx, yy)

var angle = point_direction(x, y, xx, yy);
var spd = 0;
if(avancer==1){
    spd = mySpeed; //your variable for speed
}

var xmove = lenghtdir_x(spd, angle);
var ymove = lenghtdir_y(spd, angle);

if(place_meeting(x+xmove, y+ymove, wall){    //do collision
    xmove=0;                                //oversimplified version
    ymove=0;
    avancer=0;
}

if(point_distance(x, y, xx, yy)<= spd){
    x=xx;
    y=yy;
    avancer=0;
}
else{
    x+=xmove;
    y+=ymove;
}
 
N

nb2

Guest
Yees !! it work thanks to u !!! we love u so much, we want to marry yall
 
Top