Okay here is my simple script to detect what plane the character is walking on. The script works and detects the change in plane but does not update, how can I get it to constantly check using on triggerenter, I don't want to put this in the Update function.
function OnTriggerEnter (col : Collider) {
if (col.tag == "wood")
{ print("wood");
}
if (col.tag == "forrest")
{ print("forrest");
} }
Thanks
Okay an update now.
> function OnTriggerStay (col :
> Collider) {
>
> if (!col.tag) return;
>
> var floorType : String = col.tag;
>
> switch(floorType) {
> case "wood":
> if ( Input.GetButtonDown( "Horizontal" ) || Input.GetButtonDown(
> "Vertical" ) ) {
> // play wood floor footsteps.
> audio.clip = (footStepsWood);
> audio.Play();
> }else if ( !Input.GetButton( "Horizontal" ) && !Input.GetButton(
> "Vertical" ) && audio.isPlaying ){
> audio.Pause();
> }
> break;
> case "forrest":
> if ( Input.GetButtonDown( "Horizontal" ) || Input.GetButtonDown(
> "Vertical" ) ) {
> // play forrest footsteps
> audio.clip = (footStepsForrest);
> audio.Play();
> }else if ( !Input.GetButton( "Horizontal" ) && !Input.GetButton(
> "Vertical" ) && audio.isPlaying ){
> audio.Pause();
> }
> break;
> default: //if the tag is not a floor type
> break;
> } }
This script works it changes the sound depending on the area but i have to press one of the input buttons to get it to work. Cant the sound file change on the enter of the triger? so i dont have to press down a button again?
Thanks
asked
Apr 24 '12 at 12:07 PM
1992christoff
18
●
2
●
3
●
4