Question by
xinranyu1997 · Jan 12, 2019 at 07:12 PM ·
tank
Failed to create a gamper
I want to create a barrage using vehicle game tutorial.
The gif represents what my game looks like now.
In the illustration, I explained what I want and the current status.
Actually the difference between 2 and 3 is just a for loop. I wonder why it looks good when I have just 1 layer, while it fails to create so many layers of the 5 bullets in 2?
Here is my Shot() method: private void Shot() { m_Shot = true;
for (int j = 0; j < m_ShotDirections; j++)
{
float direction;
Vector3 shotDirection;
for (int i = 0; i < m_ShotTimes; i++)
{
if (j < m_ShotDirections / 2)
{
direction = 80 - j * 40;
shotDirection = m_FireTransform.forward * (90 - direction) / 90 - m_FireTransform.right * direction / 90;
}
else if (j > m_ShotDirections / 2)
{
direction = 80 - (m_ShotDirections - 1 - j) * 40;
shotDirection = m_FireTransform.forward * (90 - direction) / 90 + m_FireTransform.right * direction / 90;
}
else
{
shotDirection = m_FireTransform.forward;
}
Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;
shellInstance.velocity = m_CurrentLaunchForce * shotDirection;
m_ShootingAudio.clip = m_FireClip;
m_ShootingAudio.Play();
m_CurrentLaunchForce = m_MinLaunchForce;
}
}
}
private void Nothing()
{
}
By the way, does anyone have any idea about how to rotate the shell rigidbody to make it align with the direction it burst out? I have been frustrated with these problems for so long.
Comment
Your answer
