PlayerRope.cs 877 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using static UnityEngine.GraphicsBuffer;
  5. public class PlayerRope : MonoBehaviour
  6. {
  7. public LineRenderer line;
  8. public Enemy targetEnemy;
  9. public int playerId;
  10. public void BeLink(Enemy enemy)
  11. {
  12. targetEnemy = enemy;
  13. gameObject.SetActive(true);
  14. }
  15. private void Update()
  16. {
  17. if (!targetEnemy)
  18. {
  19. Debug.LogError("NoTargetEnemy");
  20. gameObject.SetActive(false);
  21. return;
  22. }
  23. line.SetPosition(0, PlayersInput.instance[playerId].transform.position + Vector3.up);
  24. line.SetPosition(1, targetEnemy.transform.position + Vector3.up);
  25. }
  26. private void FixedUpdate()
  27. {
  28. if (!targetEnemy || targetEnemy.isDie)
  29. {
  30. gameObject.SetActive(false);
  31. }
  32. }
  33. }