Hey,
I’ve been playing around with 2d game and have projectile/bullet firing from the player character. However when I jump and fire at the same time the momentum of the parent object jumping is causing my projectile to go off an and angle.
Is there anyway to modify this so that the bullet will only ever have force applied to it on the x-axis?
This is the current script for firing the projectile this is attached to an object who’s parent is the player
public void Fire(bool isFacingRight)
{
var clone =
this.Instantiate(this.ProjectilePrefab, transform.position, transform.rotation) as GameObject;
var direction = isFacingRight ? 1 : -1;
clone.transform.localScale *= direction;
clone.rigidbody2D.AddForce(new Vector2(this.ProjectileSpeed * direction, 0));
}