Advertisement
Guest User

Untitled

a guest
Apr 24th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2. var _closest_ally = instance_nearest_not_me(obj_enemy_parent_2)
  3. var _avoid_x = x - _closest_ally.x,
  4. _avoid_y = y - _closest_ally.y
  5.  
  6. if !collision_circle(x, y, move_speed_max, obj_enemy_parent_2, false, true)
  7. {
  8. _avoid_x = 0;
  9. _avoid_y = 0;
  10. }
  11.  
  12.  
  13. // Update movement vector
  14. move_x = move_norm_x * move_speed;
  15. move_y = move_norm_y * move_speed;
  16.  
  17. // Add up total movement velocity
  18. var _vx = move_x + impulse_force_x + constant_force_x + _avoid_x,
  19. _vy = move_y + impulse_force_y + constant_force_y + _avoid_y;
  20.  
  21. var _object = id
  22.  
  23.  
  24.  
  25. //Normalize and set magnitude
  26. var _dist = sqrt(_vx * _vx + _vy * _vy);
  27. velocity = min(C_TERMINAL_VELOCITY, _dist);
  28. if (_dist != 0)
  29. {
  30. _vx = _vx / _dist * velocity;
  31. _vy = _vy / _dist * velocity;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement