private void Awake()
        {
            // Instantiate the explosion prefab and get a reference to the particle system on it
            m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent <ParticleSystem>();

            // Get a reference to the audio source on the instantiated prefab
            m_ExplosionAudio = m_ExplosionParticles.GetComponent <AudioSource>();

            // Disable the prefab so it can be activated when it's required
            m_ExplosionParticles.gameObject.SetActive(false);

            networkManager = GameObject.Find("NetworkManager").GetComponent <NetworkManagerTank>();
        }
        private void Fire()
        {
            // Create an instance of the shell and store a reference to it's rigidbody
            Rigidbody shellInstance;

            shellInstance = NetworkManagerTank.Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;

            // Set the shell's velocity to the launch force in the fire position's forward direction
            shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward;

            // Change the clip to the firing clip and play it
            m_ShootingAudio.clip = m_FireClip;
            m_ShootingAudio.Play();

            // Reset the launch force.  This is a precaution in case of missing button events
            m_CurrentLaunchForce = m_MinLaunchForce;
            NetworkServer.Spawn(shellInstance.gameObject);
        }
Exemple #3
0
 private void Awake()
 {
     networkManager = GameObject.Find("NetworkManager").GetComponent <NetworkManagerTank>();
     m_Camera       = GetComponentInChildren <Camera> ();
 }