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.

36 lines
961 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerController : MonoBehaviour {
  5. // Update is called once per frame
  6. void Update () {
  7. if (Input.GetButtonDown("Fire1")) {
  8. Debug.Log("Click");
  9. RaycastHit hit;
  10. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  11. LayerMask rayMask = (1 << 4);
  12. Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
  13. if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
  14. WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
  15. Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
  16. Debug.Log("I hit: " + hit.transform.name);
  17. if (waterScript != null)
  18. waterScript.CreateWave(hit.point, 10, 5);
  19. }
  20. }
  21. }
  22. }