private void EjectShell()
{
// spawn the shell
GameObject s = null;
s = (GameObject)Object.Instantiate(ShellPrefab,
m_Camera.transform.position + m_Camera.transform.TransformDirection(ShellEjectPosition),
m_Camera.transform.rotation);
s.transform.localScale = new Vector3(ShellScale, ShellScale, ShellScale);
vp_Layer.Set(s.gameObject, vp_Layer.Debris);
// send it flying
if (s.rigidbody)
s.rigidbody.AddForce((transform.TransformDirection(ShellEjectDirection) * ShellEjectVelocity), ForceMode.Impulse);
// add random spin if user defined
if (ShellEjectSpin > 0.0f)
{
if (Random.value > 0.5f)
s.rigidbody.AddRelativeTorque(-Random.rotation.eulerAngles * ShellEjectSpin);
else
s.rigidbody.AddRelativeTorque(Random.rotation.eulerAngles * ShellEjectSpin);
}
}