T
TypicalHog
Guest
I'm making a space game and I'm using physics engine.
Should I use physics_apply_local_impulse or physics_apply_local_force for ship movement and bullet firing?
Currently I'm using force for ship and impulse for bullet.
Also, another quick question: Bullets are traveling slower than ship when going fast. How do I carry ship's velocity onto bullet?
Here's the code:
// Fire bullet
if keyboard_check(vk_space) {
if alarm[0] = -1 {
physics_apply_local_impulse(0, 0, -0.25, 0); // Recoil
bullet = instance_create(x + lengthdir_x(32, phy_rotation * -1), y + lengthdir_y(32, phy_rotation * -1), obj_bullet)
with (bullet) {
phy_bullet = true;
phy_rotation = other.phy_rotation;
physics_apply_local_impulse(0, 0, 100, 0);
alarm[0] = 300; // Bullet life (5 sec)
}
alarm[0] = 15; // Cooldown (0.25 sec)
}
}
P.S. Tabs got removed
Should I use physics_apply_local_impulse or physics_apply_local_force for ship movement and bullet firing?
Currently I'm using force for ship and impulse for bullet.
Also, another quick question: Bullets are traveling slower than ship when going fast. How do I carry ship's velocity onto bullet?
Here's the code:
// Fire bullet
if keyboard_check(vk_space) {
if alarm[0] = -1 {
physics_apply_local_impulse(0, 0, -0.25, 0); // Recoil
bullet = instance_create(x + lengthdir_x(32, phy_rotation * -1), y + lengthdir_y(32, phy_rotation * -1), obj_bullet)
with (bullet) {
phy_bullet = true;
phy_rotation = other.phy_rotation;
physics_apply_local_impulse(0, 0, 100, 0);
alarm[0] = 300; // Bullet life (5 sec)
}
alarm[0] = 15; // Cooldown (0.25 sec)
}
}
P.S. Tabs got removed