My bullet prefab seems to follow player movement after firing?
I'm brand new to all this learning between youtube & unity documentation, so I've only the most basic understanding. I'm making a tiny side scrolling spaceship shooter. My problem is that the bullet prefab spawns in the correct place on the firepoint(empty object parented to player) and begins to move forward fine but it then follows the player up and down(on the x) as it moves, including the players rotation. It should just move forward (along the y axis) and nothing on the x. Anyone see what I'm doing wrong?
//on my player script
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Shoot();
}
}
void Shoot()
{
Instantiate(energyBallPrefab, firePoint);
}
//on bullet prefab script
{
public float bulletSpeed = 20f;
public Rigidbody2D rbBullet;
private void Start()
{
rbBullet.velocity = new Vector2(0, 1 * bulletSpeed);
}
Answer by GameDeveloperAf · Apr 20, 2021 at 07:33 PM
Instantiate(energyBallPrefab, firePoint, Quaternion.identity);
Your answer
Follow this Question
Related Questions
BulletPrefab spawning fine but following players movement input. 1 Answer
Issue with wave-like motion when rotating with mouse input 0 Answers
Buttons for Player movement 0 Answers
Character Diagonal Movement Issue 3 Answers
Switching lanes 1 Answer