#then assign the direction

1 messages · Page 1 of 1 (latest)

strong acorn
#

This is what I have for bullet creation:

private void FireBullet() // NOTE: Bullets when traveling sideways aren't right yet.
{
    cooldownTimer = fireDelay;

    foreach (BulletPrefabOffset bulletPrefabOffset in bulletPrefabs)
    {
        Vector2 bulletForwardDirection = playerRb.transform.up;

        // Calculate bullet offset
        Vector3 offset = transform.rotation * bulletPrefabOffset.offset;

        // Instantiate bullet
        GameObject bulletGO = Instantiate(bulletPrefabOffset.bulletPrefab, transform.position + offset, transform.rotation);
        bulletGO.layer = bulletLayer;
        

        // Initialize bullet properties
        BulletManager bulletScript = bulletGO.GetComponent<BulletManager>();
        bulletScript.InitializeBullet(bulletSpeed, playerSpeed, playerRb);
    }
}
fair peak
strong acorn
#

With a bit of debug you mean?

fair peak
#

the pivot point

#

make sure its in local mode

strong acorn
#

I'm not sure how to do all that. It's in local but I don't see any pivot points

fair peak
#

select the Move tool

#

also you're in Center mode

#

you should be in Pivot mode 97% of the time

strong acorn
#

The bullets are rotating correctly.

fair peak
#

since your bullets are uniform

#

your offset isn't correct

#

also i would just make 2 firepoint transforms instead of putting any offset in code

#

or however any max firepoints you have

strong acorn
#

The offset is where the bullets are spawned. You are recommending doing it in code instead of the editor?

fair peak
#

nah opposite

#

crude example

#

green are firepoints

#

public Transform[] firePoints;

#

then you could potentially put as many firepoints as you want and you shoot witih 1 loop

strong acorn
#

Before I dig deep into this idea, I was gonna have different ships with different layouts for how they shoot. Will tha work?

fair peak
strong acorn
#

I have to think about that because I don't fully understand. This is beginner chat :P I'm gonna wrap my head around it. I really appreciate you.

fair peak
#

sure no prob!
if you want some examples , I can show you some. I've done this type of game a few times

strong acorn
#

Anything you want to share. I learn by deconstructing codes.

fair peak
#

sure. one sec

fair peak
#

but the idea is the same