Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Playables;
- public class SpaceshipCutscene : MonoBehaviour
- {
- public Transform player;
- public Transform[] npcs;
- public Transform console;
- public Camera FPSCamera;
- public Camera mainCamera;
- public Animator[] anim;
- public float rotationSpeed = 3f;
- private bool moveNpc = false;
- // Use this for initialization
- void Start()
- {
- }
- private void Update()
- {
- if (moveNpc)
- {
- // Soldier 2 rotating and looking at player
- Vector3 dir = player.position - npcs[0].position;
- dir.y = 0; // keep the direction strictly horizontal
- Quaternion rot = Quaternion.LookRotation(dir);
- // slerp to the desired rotation over time
- npcs[0].rotation = Quaternion.Slerp(npcs[0].rotation, rot, rotationSpeed * Time.deltaTime);
- Vector3 dirToComputer = console.transform.position - npcs[1].position;
- dirToComputer.y = 0;
- Quaternion rot1 = Quaternion.LookRotation(dirToComputer);
- npcs[1].rotation = Quaternion.Slerp(npcs[1].rotation, rot1, rotationSpeed * Time.deltaTime);
- }
- }
- private void OnTriggerExit(Collider other)
- {
- if (other.gameObject.tag == "SpaceshipCutscene")
- {
- FPSCamera.enabled = false;
- mainCamera.enabled = true;
- moveNpc = true;
- anim[0].SetTrigger("SoldierAimingTrigger");
- anim[1].SetTrigger("SoldierWalkingTrigger");
- }
- }
- }
Add Comment
Please, Sign In to add comment