Hello guys, I’ve got a problem with trigger, here it’s code :
using UnityEngine;
using System.Collections;
public class Trigger : MonoBehaviour {
public AudioClip watersound;
private bool InWater;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnTriggerEnter(Collider other){
if(other.tag == "Water" && Camera.main.audio.isPlaying != true)
{
Camera.main.audio.clip = watersound;
Camera.main.audio.Play();
PlayerScript.Pspeed = 0.007f;
InWater = true;
}
else if(other.tag == "Ground" && Camera.main.audio.isPlaying != true)
{
InWater = false;
PlayerScript.Pspeed = 0.016f;
}
}
}
the trigger should make player speed slower when it touch the blue square, but it doesn’t do that, I can say better, it’s do nothing =/, here’re some screens :
and another screen, all squares have got a rigidbody attached