TargetAnimal.cs 747 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class TargetAnimal : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. }
  10. // Update is called once per frame
  11. void Update()
  12. {
  13. }
  14. public virtual void OnHit(Arrow arrow, Vector3 hitPoint, string partName)
  15. {
  16. }
  17. public float CalculateDistanceInHorizontal(Vector3 p1, Vector3 p2)
  18. {
  19. float deltaX = p2.x - p1.x;
  20. float deltaZ = p2.z - p1.z;
  21. return Mathf.Sqrt(deltaX * deltaX + deltaZ * deltaZ);
  22. }
  23. public void RandomRotate(float angle) {
  24. transform.forward = Quaternion.AngleAxis(angle, Vector3.up) * transform.forward;
  25. }
  26. }