using UnityEngine;
using System.Collections;
//[RequireComponent(typeof(CharacterController))]
//[RequireComponent(typeof(Rigidbody))]
public class MovieControl : MonoBehaviour {
public float speed = 3.0f;
public float rotateSpeed = 3.0f;
private CharacterController controller;
private Vector3 forward;
private float curSpeed = 0.0f;
public Transform bullitPrefab;
public Transform Spawn;
private GameObject fireBullit;
private bool dead = false;
void OnCollisionEnter(Collision hit){
if(hit.gameObject.tag=="fallout")
{
// hit.gameObject.renderer.enabled = false;
dead = true;
}
}
void Awake () {
//controller = gameObject.GetComponent(typeof(CharacterController)) as CharacterController;
controller = GetComponent<CharacterController>();
}
void Update () {
transform.Rotate(0, Input.GetAxis("Horizontal")*rotateSpeed, 0);
forward = transform.TransformDirection(Vector3.forward);
curSpeed = speed*Input.GetAxis("Vertical");
controller.SimpleMove(forward*curSpeed);
if (Input.GetButtonDown("Jump")) {
fireBullit = (GameObject)Instantiate(bullitPrefab.gameObject,
Spawn.position, Quaternion.identity);
fireBullit.rigidbody.AddForce(forward * 2000f);
}
}
void LateUpdate(){
if(dead == true)
{
transform.position = new Vector3(0, 4, 0);
GameObject.Find("MainCamera").transform.position = new Vector3(0, 4, -10);
dead = false;
}
}
}