Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class EnemyTouchScript : MonoBehaviour
  7. {
  8. Vector3 startPoint; //place where player collides
  9. Vector3 endPoint; //place where player respawns
  10. float timeToRespawn;//
  11. static float currentTime;//variable that's being cumulated to <=1
  12.  
  13. GameObject Neo; //player
  14. bool isTouched;
  15.  
  16. LerpHelper_Script lerp = new LerpHelper_Script();
  17. private void Start()
  18. {
  19. Neo = GameObject.FindGameObjectWithTag("Player");
  20.  
  21. endPoint = Neo.GetComponent<MovementScript>().respawnPoint;
  22. currentTime = 0f;
  23.  
  24. isTouched = false;
  25. }
  26.  
  27. private void Update()
  28. {
  29. if (isTouched==true)
  30. {
  31. transform.position=lerp.CallLerp(startPoint,endPoint);
  32. if (transform.position == endPoint)
  33. {
  34. currentTime = 0f;
  35. }
  36. }
  37. }
  38.  
  39. private void OnTriggerEnter2D(Collider2D collision)
  40. {
  41. if (collision.tag == "Dinosaur_Enemy")
  42. {
  43. isTouched = true;
  44. startPoint = transform.position;
  45. }
  46. }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement