Hey guys! Creeperbot65 here!
I’m having an error with rotating my cut scene camera and it just won’t rotate at all no matter what I do! Same thing goes for the door opening animation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class StartingScene : MonoBehaviour {
public Text DialougeBox;
private double Timer;
public AudioClip FootstepSound1;
public AudioClip FootstepSound2;
public AudioClip FootstepSound3;
public AudioClip FootstepSound4;
public AudioClip DoorOpen;
public Transform Player;
private int RandomFootStep;
public GameObject Darkness;
public Transform Door;
public bool StartingSceneEnabled;
void Awake () {
StartingSceneEnabled = true;
DialougeBox.text = "";
}
void Update () {
//Increaces the time in seconds for dialouge
if (Time.time > Timer && Timer < 26) {
if (Timer != 24) {
Timer = Mathf.Round (Time.time + 1);
}
if (tag != "Player") {
if (Timer < 21) {
RandomFootStep = Random.Range (1, 4);
if (RandomFootStep == 1) {
AudioSource.PlayClipAtPoint (FootstepSound1, new Vector3 (Player.position.x, Player.position.y, Player.position.z));
} else if (RandomFootStep == 2) {
AudioSource.PlayClipAtPoint (FootstepSound2, new Vector3 (Player.position.x, Player.position.y, Player.position.z));
} else if (RandomFootStep == 3) {
AudioSource.PlayClipAtPoint (FootstepSound3, new Vector3 (Player.position.x, Player.position.y, Player.position.z));
} else if (RandomFootStep == 4) {
AudioSource.PlayClipAtPoint (FootstepSound4, new Vector3 (Player.position.x, Player.position.y, Player.position.z));
}
}
}
} else if (Timer > 23) {
if (tag != "Player") {
DialougeBox.text = "";
if (Timer == 24) {
AudioSource.PlayClipAtPoint (DoorOpen, new Vector3 (Player.position.x, Player.position.y, Player.position.z));
for (int i = 0; i > 900; i++) {
//Error is here!
Door.Rotate (0, 0.10f, 0);
Door.position = new Vector3 (Door.position.x + 0.00074444444f, Door.position.y, Door.position.z + 0.00063333333f);
}
Timer = 25;
}
if (Timer == 27) {
Timer = 28;
GameObject MusicBGGameobject = GameObject.Find ("FPSController");
BGMusic BGMusicScript = MusicBGGameobject.GetComponent<BGMusic> ();
BGMusicScript.MusicSel = 2;
BGMusicScript.PlayMusic = true;
Instantiate (Darkness, new Vector3 (-0.2f, 1.09f, 8.28f), new Quaternion (0, 0, 0, 0));
StartingSceneEnabled = false;
}
}
}
//The starting texts
if (tag != "Player") {
if (Timer == 2) {
DialougeBox.text = "Gees, My friends are such a******s.";
} else if (Timer == 6) {
DialougeBox.text = "Forcin' me to go down here or else they'll burn my house down.";
} else if (Timer == 12) {
DialougeBox.text = "";
} else if (Timer == 15) {
DialougeBox.text = "They certainly don't sound like friends now.";
} else if (Timer == 19) {
DialougeBox.text = "";
} else if (Timer == 23) {
//Error is here!
float tiltAroundY = Player.rotation.y;
float tiltAroundX = 38.29f;
float tiltAroundZ = Player.rotation.z;
Quaternion target = Quaternion.Euler (tiltAroundX, tiltAroundY, tiltAroundZ);
Player.rotation = Quaternion.Slerp (Player.rotation, target, 0.1f);
DialougeBox.text = "I'm here...";
}
}
//Scripts for moving player
if (Timer < 19) {
Player.transform.position = new Vector3 (Player.transform.position.x, Player.transform.position.y - 0.01f, Player.transform.position.z + 0.01f);
}
}
}
Thanks!
-creeperbot65