using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerController : MonoBehaviour {
|
|
|
|
public float power;
|
|
public float radius;
|
|
public float time;
|
|
|
|
public GameObject waveRing;
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
if (Input.GetButtonDown("Fire1")) {
|
|
Debug.Log("Click");
|
|
RaycastHit hit;
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
LayerMask rayMask = (1 << 4);
|
|
|
|
Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
|
|
|
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
|
|
|
|
Vector3 pos = hit.point;
|
|
pos.y += 1;
|
|
Quaternion rot = Quaternion.Euler(-90, 0, 0);
|
|
|
|
if (waveRing != null)
|
|
Destroy(Instantiate(waveRing, pos, rot),4);
|
|
|
|
|
|
WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
|
|
Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
|
|
|
|
Debug.Log("I hit: " + hit.transform.name);
|
|
if (waterScript != null)
|
|
waterScript.CreateWave(hit.point, radius, power);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|