• 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!

Legacy GM Precise collision

R

Rodimus

Guest
Hello!

I have five objects: one is a car, the other four is arrows, represent up,down,left, right. They supposed to turn the car to the respective directions. My problem begins here: I want the car EXACTLY turning, when its center is matching the arrow's center, behind it. How can I do this? Here is what I so far get:

My codes working, but not perfectly. how can I make it precise?

Thanks for any help!

spd = 30;
newdir = direction;

image_angle = direction;

repeat (spd)
{
if (direction != newdir)
{
if (x % 32 == 16 && y % 32 == 16)
{
direction = newdir;
}
}
x= x+lengthdir_x(1,direction);
y= y+lengthdir_y(1,direction);
}

newdir = other.direction;

room.png
 
D

Docker

Guest
could you not have it so when the x and y of the car and the x and y of the respective arrow are equal then complete the rotation? This is on the assumption that both sprites are centered and the center points will meet.
 
R

Rodimus

Guest
Yes, I forgot to add this, the sprites are centered (16;16 the origion), they met, the car turning, but if I increase the speed of the car, It's not working anyore.
 
R

renex

Guest
You need a margin at which to turn the car. If you compare precise coordinates like that, chances are they'll never meet.

On collision with the arrow, check if point_distance(x,y,other.x,other.y) is smaller than 8. That should give you a circle of radius 8 at which the arrows work.
 
R

Rodimus

Guest
But it's not mean that, the difference is +-8? It'll turning exactly at the center? As you can see, this is a race trac on the image attached to the thread, so it must works like a "rail".
 
R

renex

Guest
Then use a radius of 'speed'. This ensures the arrow is found at any speed.

You should also center the car at the arrow when it turns, to increase precision. I suggest you move your turning code to the collision event.
 
R

Rodimus

Guest
The turning code seems like ignored i collision event, but the centering is ok. If this won't work, I use some checkpoint style following with 3 "rail" (points stored in list or array for each line). Thanks for your answer!
 
Top