Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _closest_ally = instance_nearest_not_me(obj_enemy_parent_2)
- var _avoid_x = x - _closest_ally.x,
- _avoid_y = y - _closest_ally.y
- if !collision_circle(x, y, move_speed_max, obj_enemy_parent_2, false, true)
- {
- _avoid_x = 0;
- _avoid_y = 0;
- }
- // Update movement vector
- move_x = move_norm_x * move_speed;
- move_y = move_norm_y * move_speed;
- // Add up total movement velocity
- var _vx = move_x + impulse_force_x + constant_force_x + _avoid_x,
- _vy = move_y + impulse_force_y + constant_force_y + _avoid_y;
- var _object = id
- //Normalize and set magnitude
- var _dist = sqrt(_vx * _vx + _vy * _vy);
- velocity = min(C_TERMINAL_VELOCITY, _dist);
- if (_dist != 0)
- {
- _vx = _vx / _dist * velocity;
- _vy = _vy / _dist * velocity;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement