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.

40 lines
1.0 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. // Update is called once per frame
  9. void Update () {
  10. if (Input.GetButtonDown("Fire1")) {
  11. Debug.Log("Click");
  12. RaycastHit hit;
  13. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  14. LayerMask rayMask = (1 << 4);
  15. Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
  16. if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
  17. WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
  18. Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
  19. Debug.Log("I hit: " + hit.transform.name);
  20. if (waterScript != null)
  21. waterScript.CreateWave(hit.point, radius, power);
  22. }
  23. }
  24. }
  25. }