X
XirmiX
Guest
I've been trying to set up a recoil for when I shoot a projectile for my game. The game is physics based and currently the projectile, after being spawned in will trigger an alarm, which will occur after 1 frame upon it being spawned. Within the alarm is the following code:
This doesn't exactly do what I expect it to do. Remember this is a tank that is controlled. The obj_turret is the weapon and the obj_hull is the base part (this is a top-down shooter I'm working on btw). I'm expecting to have the projectile, when spawned (so, I guess the alarm doesn't really have much of a purpose) to push the hull a little bit in the opposite direction the projectile is travelling or in the opposite image_angle/direction of the turret. With what I've done so far, the hull moves, but always in the opposite direction IT is facing and not in the opposite direction to which the TURRET is facing.
Code:
with(obj_hull)
{
var recoil = phy_mass * acceleration;
physics_apply_local_force(obj_turret.image_angle,0,-recoil,0)
}