T2008
Member
I would like my bullet to adjusted it's direction if solid object is in collision line. Not sure of how to do this. My Bullet Code is below (relevant parts). It doesn't work; I added the collision line part, but originally just said direction = 0 (which didn't work also). The robot is in correct direction but because it's bullet is way smaller, it can hit a solid along a corner and player can hide behind wall while robot is just shooting corner of wall.
Any ideas would be greatly appreciated!
Bullet Create Event:
Any ideas would be greatly appreciated!
Bullet Create Event:
Code:
//Set Direction
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_e) {
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 0;
} else { direction = 10; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_ne) {
//direction = 45;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 45;
} else { direction = 55; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_n) {
//direction = 90;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 90;
} else { direction = 100; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_nw) {
//direction = 135;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 135;
} else { direction = 145; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_w) {
//direction = 180;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 180;
} else { direction = 190;}
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_sw) {
//direction = 225;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 225;
} else { direction = 235; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_s) {
//direction = 270;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 270;
} else { direction = 280; }
}
if (obj_robot_rng.sprite_index = spr_robot_rng_shoot_se) {
//direction = 315;
if (!collision_line(x,y,obj_player.x,obj_player.y,obj_bullet_only_solid,false,false)) {
direction = 315;
} else { direction = 325; }
}