• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Fireballs changing direction with player

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
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;
    }
and this is in the step event of the fireball
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);
}
 
D

Daz@mbi

Guest
Try setting the direction of the fireball in the fireballs create event.
 
Top