using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WindTunnel : MonoBehaviour {

	SailSpeed sail;
	CapsuleCollider col;
	Transform thisTF;
	[SerializeField] LayerMask playerMask;
	void Start () {
		col = GetComponent<CapsuleCollider> ();
		thisTF = GetComponent<Transform> ();
		sail = GameObject.Find ("player").GetComponent<SailSpeed> ();
	}
	[SerializeField] AudioClip clip;
	bool thing;
	// Update is called once per frame
	void Update () {
		if (Physics.CheckCapsule (thisTF.position, thisTF.position + thisTF.forward * col.height, col.radius, playerMask)) {
			sail.AddSpeed (thisTF.forward);
			if (!thing) {
				sail.GetComponent<AudioSource> ().PlayOneShot (clip, 1f);
				thing = true;
			}
		}
	}
}
