Search Unity

Mesh colliding from surface > Play shot

Discussion in 'Scripting' started by xxlilxjxx, Sep 20, 2014.

  1. xxlilxjxx

    xxlilxjxx

    Joined:
    Jul 21, 2014
    Posts:
    28
    This script I got is supposed to play a shot of a sound while my player touches the floor.
    But it only works when actually inside the mesh collider. (Discovered this with water)
    Being on top of the mesh collider does nothing
    Is it possible to have it play when on top?
    - I am trying to make walking sounds


    #pragma strict

    private var footsteps : PlayerFootsteps;

    function Start()
    {
    footsteps = GameObject.Find("First Person Controller").GetComponent(PlayerFootsteps);
    }

    function OnTriggerEnter (Col : Collider) //Id guess this is what needs to be changed?
    {
    if(Col.gameObject.tag == "Player")
    {
    footsteps.inWater = true; // Setting to true makes the sound play
    }
    }

    function OnTriggerExit (Col : Collider)
    {
    if(Col.gameObject.tag == "Player")
    {
    footsteps.inWater = false; //Setting to false makes the sound stop
    }
    }
     
  2. xxlilxjxx

    xxlilxjxx

    Joined:
    Jul 21, 2014
    Posts:
    28