Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @description Update shell x, y, z
- // shell is not immediately armed, arming = 0 is considered armed
- if (arming > 0) arming -=1;
- // update time since shell was fired
- time_of_flight += 1 / room_speed;
- // gravity
- var g = -9.8 * 10;
- // update distance_travelled
- distance_travelled = velocity_h * time_of_flight;
- show_debug_message("Distance travelled: " + string(distance_travelled) + " at a time of " + string(time_of_flight));
- // update horizontal axises
- x = origin_x + lengthdir_x(distance_travelled, direction);
- y = origin_y + lengthdir_y(distance_travelled, direction);
- // this formula is for parabolic trajectory, not used, doesn't account for degrees or radians properly
- //var displacement_z = ( tan(theta) * time_of_flight - (g / ( 2 * power(v, 2) * sqr(cos(theta)) ) ) * power(time_of_flight, 2) );
- // convert velocity per tick to velocity per second
- var v = shell_velocity * room_speed;
- // vertical displacement at point in time, this formula is for z displacement
- var displacement_z = ( (velocity_v * time_of_flight) + 0.5 * (g) * sqr(time_of_flight) );// *-1
- // update z axis
- z = origin_z + displacement_z;
- // check if shell is under water
- if (z < 0) is_under_water = true;
- // update depth to be opposite of z, in gms negative depth is closer to camera, while positive z is above water line
- depth = -1 * z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement