Hello,
Having some trouble with getting a consistent spread on shotgun bullets, regardless of the direction the character is facing. What I have is fine if the character is facing vertically, but the bullets clump together when facing horizontally. Here’s what I’ve got so far.
EDIT: The distance the mouse is from the character changes the input rotation var, and consequently affects the bullet’s spread.
I’m fairly new to unity, and only understand the basics of quaternions, so a simple solution would be great. Thanks for your time!
if(currentWeaponType == "Shotgun")
{
Debug.Log("PlayerScript.HandleBullets(): Shotgun Fired. Input rotation is:" + inputRotation);
Vector3 bullet2Angle = inputRotation;
bullet2Angle.x -= 15;
bullet2Angle.z -= 15;
Vector3 bullet2Vector = tempVector;
bullet2Vector.x -= 0.3f;
bullet2Vector.z -= 0.3f;
Vector3 bullet3Angle = inputRotation;
bullet3Angle.x += 15;
bullet3Angle.z -= 15;
Vector3 bullet3Vector = tempVector;
bullet3Vector.x += 0.3f;
bullet3Vector.z += 0.3f;
GameObject bullet1 = (GameObject) Instantiate(bullet, tempVector, Quaternion.LookRotation(inputRotation));
GameObject bullet2 = (GameObject) Instantiate(bullet, bullet2Vector, Quaternion.LookRotation(bullet2Angle));
GameObject bullet3 = (GameObject) Instantiate(bullet, bullet3Vector, Quaternion.LookRotation(bullet3Angle));
}