A
Arikitaru
Guest
Hello! I'm having a weird issue with a camera/shooting feature of my game.
Whenever I'm trying to shoot, the bullets are leaving from the right spot (turret), but not towards my cursor - the game thinks that the turret is about 200px higher. If I rotate my cursor around that marked spot while shooting - it's behaving properly. Note: I have a zoom feature for my camera and whenever the camera object is off, turrets behave properly.
Bullet code:
Camera code:
Will appreciate any advice as I'm stuck here for some time now. Checked my previous build - turrets are working properly, since then I was only working on adding some spawners, new type of projectiles and enemies. Cheers!
Whenever I'm trying to shoot, the bullets are leaving from the right spot (turret), but not towards my cursor - the game thinks that the turret is about 200px higher. If I rotate my cursor around that marked spot while shooting - it's behaving properly. Note: I have a zoom feature for my camera and whenever the camera object is off, turrets behave properly.
Bullet code:
Code:
gravity = 0.11;
direction = point_direction(x,y,mouse_x,mouse_y);
direction += random_range(-4,4);
speed = 15;
image_angle = direction;
Code:
//Create
target = obj_rig_lg;
orig_x_size = 1280;
orig_y_size = 720;
zoom = 1;
target_zoom = zoom;
//Step
var cam_id = view_camera[0];
x += (target.x - x) * scroll_spd;
y += (target.y - y) * scroll_spd;
zoom += (target_zoom - zoom) * zoom_spd;
camera_set_view_size(cam_id, orig_x_size*zoom, orig_y_size*zoom);
var cam_width = camera_get_view_width(cam_id);
var cam_height = camera_get_view_height(cam_id);
camera_set_view_pos (cam_id, x-cam_width * 0.5, y-cam_height * 0.5);
var mouse_input = mouse_wheel_down() - mouse_wheel_up();
target_zoom += mouse_input;
target_zoom = clamp (target_zoom, 0.5, 4);