Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyTouchScript : MonoBehaviour
- {
- Vector3 startPoint; //place where player collides
- Vector3 endPoint; //place where player respawns
- float timeToRespawn;//
- static float currentTime;//variable that's being cumulated to <=1
- GameObject Neo; //player
- bool isTouched;
- LerpHelper_Script lerp = new LerpHelper_Script();
- private void Start()
- {
- Neo = GameObject.FindGameObjectWithTag("Player");
- endPoint = Neo.GetComponent<MovementScript>().respawnPoint;
- currentTime = 0f;
- isTouched = false;
- }
- private void Update()
- {
- if (isTouched==true)
- {
- transform.position=lerp.CallLerp(startPoint,endPoint);
- if (transform.position == endPoint)
- {
- currentTime = 0f;
- }
- }
- }
- private void OnTriggerEnter2D(Collider2D collision)
- {
- if (collision.tag == "Dinosaur_Enemy")
- {
- isTouched = true;
- startPoint = transform.position;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement