#then assign the direction
1 messages · Page 1 of 1 (latest)
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);
}
}
show the bullets default pointing direction btw
With a bit of debug you mean?
I'm not sure how to do all that. It's in local but I don't see any pivot points
select the Move tool
also you're in Center mode
you should be in Pivot mode 97% of the time
The bullets are rotating correctly.
hmm looks alright, you can either choose either transform.up or transorm.right
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
The offset is where the bullets are spawned. You are recommending doing it in code instead of the editor?
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
Before I dig deep into this idea, I was gonna have different ships with different layouts for how they shoot. Will tha work?
yeah wouldn't it be easier if each one has actual spawn points you can fix/rotate the direction of bullet directly inside inspector instead of doing extra math ?
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.
sure no prob!
if you want some examples , I can show you some. I've done this type of game a few times
Anything you want to share. I learn by deconstructing codes.
sure. one sec
https://hatebin.com/gqgfzlkyqr (Ship code)
my example just rotates towards mouse, i have my other projects on my home PC
but the idea is the same
https://hatebin.com/qmfcdizusq (bullet code)