Exemple #1
0
        void OnTriggerEnter(Collider other)
        {
            if (_fT == null)
            {
                return;
            }

            if (other.GetComponent <Terrain>() != null) //Check if trigger objet is a terrain
            {
                _fT.StepOnTerrain(new FootStepObject(transform, other.transform));
            }
            else
            {
                var stepHandle = other.GetComponent <vFootStepHandler>();
                var renderer   = other.GetComponent <Renderer>();
                //Check renderer
                if (renderer != null && renderer.material != null)
                {
                    var index = 0;
                    var _name = string.Empty;
                    if (stepHandle != null && stepHandle.material_ID > 0)// if trigger contains a StepHandler to pass material ID. Default is (0)
                    {
                        index = stepHandle.material_ID;
                    }
                    if (stepHandle)
                    {
                        // check  stepHandlerType
                        switch (stepHandle.stepHandleType)
                        {
                        case vFootStepHandler.StepHandleType.materialName:
                            _name = renderer.materials[index].name;
                            break;

                        case vFootStepHandler.StepHandleType.textureName:
                            _name = renderer.materials[index].mainTexture.name;
                            break;
                        }
                    }
                    else
                    {
                        _name = renderer.materials[index].name;
                    }
                    _fT.StepOnMesh(new FootStepObject(transform, other.transform, _name));
                }
            }
        }
Exemple #2
0
        void OnTriggerEnter(Collider other)
        {
            if (_fT == null)
            {
                return;
            }

            if ((lastCollider == null || lastCollider != other) || footstepObj == null)
            {
                footstepObj  = new FootStepObject(transform, other);
                lastCollider = other;
            }

            if (footstepObj.isTerrain) //Check if trigger objet is a terrain
            {
                _fT.StepOnTerrain(footstepObj);
            }
            else
            {
                _fT.StepOnMesh(footstepObj);
            }
        }