You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerController : MonoBehaviour {
  5. public float power;
  6. public float radius;
  7. public float time;
  8. public GameObject waveRing;
  9. // Update is called once per frame
  10. void Update () {
  11. if (Input.GetButtonDown("Fire1")) {
  12. Debug.Log("Click");
  13. RaycastHit hit;
  14. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  15. LayerMask rayMask = (1 << 4);
  16. Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
  17. if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
  18. Vector3 pos = hit.point;
  19. pos.y += 1;
  20. Quaternion rot = Quaternion.Euler(-90, 0, 0);
  21. if (waveRing != null)
  22. Destroy(Instantiate(waveRing, pos, rot),4);
  23. WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
  24. Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
  25. Debug.Log("I hit: " + hit.transform.name);
  26. if (waterScript != null)
  27. waterScript.CreateWave(hit.point, radius, power);
  28. }
  29. }
  30. }
  31. }