I am having the following issue shown attached. When instantiating my bullet prefab from the designated transform, I cannot shoot in the opposite direction correctly.
My PlayerBullet prefab has its own script to set the velocity of the object once it is spawned. It obviously works in one direction but I feel the way I am flipping the IK sprite might have something to do with it as I do not flip it via the SpriteRenderer but rather through the localScale of the character. Using the SpriteRenderer messes with the 2D IK bones and generally breaks the character.
Here is the PlayerBullet Code:
public class PlayerBullet : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] float _bulletSpeed;
private Rigidbody2D _rb;
void Start()
{
_rb = GetComponent<Rigidbody2D>();
_rb.velocity = new Vector2(_bulletSpeed, 0);
}
// Update is called once per frame
void Update()
{
}
}
Here is the section of the player controller that instantiates the prefab:
if (_isAttacking && _canFireWeapon)
{
_upperBodyAnimator.CrossFade("s_shoot", 0, 0);
StartCoroutine(FireWeapon(_fireRate));
}
IEnumerator FireWeapon(float fireRate)
{
_canFireWeapon = false;
Instantiate(_bulletPrefab, _bulletSpawner.transform.position, transform.rotation);
yield return new WaitForSeconds(fireRate);
_canFireWeapon = true;
}