Advertisement
Guest User

test

a guest
Nov 19th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class camtrigger : MonoBehaviour
  6. {
  7.     private bool islerping = false;
  8.     public GameObject _camera;
  9.     public GameObject campos;
  10.     public float speed = 1;
  11.  
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.        
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update()
  20.     {
  21.         if (islerping == true)
  22.         {
  23.             _camera.transform.position = Vector3.Slerp(_camera.transform.position, campos.transform.position, speed * Time.deltaTime);
  24.             _camera.transform.rotation = Quaternion.Slerp(_camera.transform.rotation, campos.transform.rotation, speed * Time.deltaTime);
  25.         }
  26.     }
  27.     private void OnTriggerEnter(Collider other)
  28.     {
  29.         if (other.gameObject.tag == "Player")
  30.         {
  31.             islerping = true;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement