SHARE
TWEET

obj_shell_step_event

a guest Aug 29th, 2019 177 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @description Update shell x, y, z
  2.  
  3. // shell is not immediately armed, arming = 0 is considered armed
  4. if (arming > 0) arming -=1;
  5.  
  6. // update time since shell was fired
  7. time_of_flight += 1 / room_speed;
  8.  
  9. // gravity
  10. var g = -9.8 * 10;
  11.  
  12. // update distance_travelled
  13. distance_travelled = velocity_h * time_of_flight;
  14.  
  15. show_debug_message("Distance travelled: " + string(distance_travelled) + " at a time of " + string(time_of_flight));
  16.  
  17. // update horizontal axises
  18. x = origin_x + lengthdir_x(distance_travelled, direction);
  19. y = origin_y + lengthdir_y(distance_travelled, direction);
  20.  
  21. // this formula is for parabolic trajectory, not used, doesn't account for degrees or radians properly
  22. //var displacement_z = ( tan(theta) * time_of_flight - (g / ( 2 * power(v, 2) * sqr(cos(theta)) ) ) * power(time_of_flight, 2) );
  23.  
  24. // convert velocity per tick to velocity per second
  25. var v = shell_velocity * room_speed;
  26.  
  27. // vertical displacement at point in time, this formula is for z displacement
  28. var displacement_z = ( (velocity_v * time_of_flight) + 0.5 * (g) * sqr(time_of_flight) );// *-1
  29.  
  30. // update z axis
  31. z = origin_z + displacement_z;
  32.  
  33. // check if shell is under water
  34. if (z < 0) is_under_water = true;
  35.  
  36. // update depth to be opposite of z, in gms negative depth is closer to camera, while positive z is above water line
  37. depth = -1 * z
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top