slicky-grease
Member
I been working on a laser like weapon for my game and I got it to work. But for some strange reason the beam itself wont kill the enemy, I will have to get up close. The actual beam drawn just go through the enemy and doesn't take ant damage.
Step Event of Laser
Draw Event
Script for Laser Damage
Step Event of Laser
GML:
x = obj_player.x;
y = obj_player.y;
dir = point_direction(0, 0, gamepad_axis_value(0,gp_axislh), gamepad_axis_value(0,gp_axislv))
dir = round(dir / 45) * 45// Snaps the Direction of the Weapon
var max_length = 900;
for ( i = 0; i < max_length; i++) {
xEnd = x + lengthdir_x(max_length,dir);
yEnd = y + lengthdir_y(max_length,dir);
length_laser = i;
}
if(timer == 30) {
instance_destroy();
}
timer++
GML:
draw_line(x,y,xEnd,yEnd);
for (j = 0; j < length_laser; j++)
{
draw_sprite_ext(spr_heatvision,1,x +lengthdir_x(j,dir), y + lengthdir_y(j,dir),1,1,dir,c_white,1 )
}
Script for Laser Damage
GML:
function scr_heatvisiondamage(){
var laser = instance_place(x,y,obj_laser)
if(laser)
{
death_bullet = true
instance_destroy(laser)
hp--;
flash = 3
state = enemy.enemy_hit
}
}function scr_heatvisiondamage(){
var laser = instance_place(x,y,obj_laser)
if(laser)
{
death_bullet = true
instance_destroy(laser)
hp--;
flash = 3
state = enemy.enemy_hit
}
}