How to make "sticky actor"
Posted: Tue Aug 05, 2014 4:32 pm
I want to make actor,which doesn't detach from the second actor, but how to do this?
Game Editor discussion board
http://game-editor.com/forum/
// this assumes there is only one gray actor for simplicity
int radius = (width + height) / 4; // using an average of height and width for simplicity
int gray_radius = (gray.width + gray.height) / 4;
int max_dist = radius + gray_radius;
if(distance(x, y, gray.x, gray.y) > max_dist))
{
float ang = direction(gray.x, gray.y, x, y);
x = gray.x + cos(ang)*max_dist;
y = gray.y - sin(ang)*max_dist;
}