Trying to spawn gameobjects with a specfic rotation so when it’s spawned it it goes forward to wherever it’s rotated to. But it always spawns rotated default (local axis facing world axis). I assume it’s because I didn’t properly converted Vector3 to Quaternion. Btw raycast’s work as intended. I appreciate any help.
int x = -45;
if (gunProp.gunType == GunManager.GunType.Shotgun)
{
for (int i = 0; i < 15; i++)
{
dir = Quaternion.AngleAxis(x, Vector3.up) * bulletSpawn.forward;
Ray ray1 = new Ray(bulletSpawn.position, dir);
RaycastHit hit;
if (Physics.Raycast(ray1, out hit, gunProp.shootDistance))
{
gunProp.shootDistance = hit.distance;
}
Debug.DrawRay(ray1.origin, ray1.direction * gunProp.shootDistance, Color.red, 1);
spawnVfx(dir);
x = x + 6;
}
}
void spawnVfx(Vector3 a)
{
GameObject vfx;
if (bulletSpawn != null)
vfx = Instantiate(effectToSpawn, bulletSpawn.position, Quaternion.Euler(a));
}