Пример #1
0
    /// <summary>
    /// OnTriggerEnter is called when the Collider other enters the trigger.
    /// </summary>
    /// <param name="other">The other Collider involved in this collision.</param>

    /*
     * void OnTriggerEnter(Collider other) {
     *  // Debug.Log( LayerMask.LayerToName( other.gameObject.layer) );
     *
     *  Instantiate( impactParticles, transform.position, Quaternion.identity );
     *
     *  RestoreBullet();
     *
     * }
     *
     * /// <summary>
     * /// OnTriggerStay is called once per frame for every Collider other
     * /// that is touching the trigger.
     * /// </summary>
     * /// <param name="other">The other Collider involved in this collision.</param>
     * void OnTriggerStay( Collider other ) {
     *  RestoreBullet();
     * }
     *
     * /// <summary>
     * /// OnTriggerExit is called when the Collider other has stopped touching the trigger.
     * /// </summary>
     * /// <param name="other">The other Collider involved in this collision.</param>
     * void OnTriggerExit(Collider other) {
     *  RestoreBullet();
     * }
     */

    /// <summary>
    /// OnCollisionEnter is called when this collider/rigidbody has begun
    /// touching another rigidbody/collider.
    /// </summary>
    /// <param name="other">The Collision data associated with this collision.</param>
    void OnCollisionEnter(Collision other)
    {
        // display bullet impact particle effect if neccesary.
        ShootingImpact impact = other.gameObject.GetComponent <ShootingImpact>();

        if (impact != null)
        {
            impact.DisplayImpact(transform.position);
        }
        // old effect.
        /// Instantiate( impactParticles, transform.position, Quaternion.identity );

        RestoreBullet();
    }
Пример #2
0
    /// <summary>
    /// OnCollisionEnter is called when this collider/rigidbody has begun
    /// touching another rigidbody/collider.
    /// </summary>
    /// <param name="other">The Collision data associated with this collision.</param>
    void OnCollisionEnter(Collision other)
    {
        // display bullet impact particle effect if neccesary.
        ShootingImpact impact = other.gameObject.GetComponent <ShootingImpact>();

        if (impact != null)
        {
            impact.DisplayImpact(transform.position);
        }

        // show charging impact effect.
        var instance = Instantiate(impactEffect, transform.position, Quaternion.identity);

        instance.transform.parent = null;
        Destroy(instance, 2.5f);

        base.RestoreBullet();

        ResetChargedBullet();
    }