S
SuperSlim
Guest
The player creates a fireball and it moves away from the player but when the player changes direction the fireball changes direction with him. How do I fix this? I am using the physics system.
this is the fireball creation code
and this is in the step event of the fireball
this is the fireball creation code
Code:
if (gamepad_button_check_pressed(0, gp_face3) && attacked == false){
switch (dir){
case 0:
instance_create(x+32, y, obj_fireball);
break;
case 1:
instance_create(x+32, y-32, obj_fireball);
break;
case 2:
instance_create(x, y-32, obj_fireball);
break;
case 3:
instance_create(x-32, y-32, obj_fireball);
break;
case 4:
instance_create(x-32, y, obj_fireball);
break;
case 5:
instance_create(x-32, y+40, obj_fireball);
break;
case 6:
instance_create(x, y+40, obj_fireball);
break;
case 7:
instance_create(x+32, y+40, obj_fireball);
break;
}
obj_fireball.dir = dir;
attacked = true;
alarm [1] = room_speed/8;
}
Code:
// move in the direction
var xforce = lengthdir_x(10, obj_player.dir*45);
var yforce = lengthdir_y(10, obj_player.dir*45);
with(other){
physics_apply_impulse(x, y, xforce, yforce);
}