Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityStandardAssets.Characters.FirstPerson;
- public class Pergamino : MonoBehaviour {
- public Transform PosNewPergamino;
- public Transform PosAntigua;
- public bool PergaminoTomado = false;
- public FirstPersonController fps;
- void Start () {
- PergaminoTomado = false;
- }
- void Update () {
- fps = GameObject.FindGameObjectWithTag ("Player").GetComponent<FirstPersonController>();
- PosNewPergamino = GameObject.Find ("PergaminoTomado").GetComponent<Transform> ();
- if (PergaminoTomado){
- transform.Rotate (Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0);
- }
- if (PergaminoTomado && Input.GetKeyDown(KeyCode.Mouse0)) {
- PergaminoTomado = false;
- transform.SetParent (null);
- fps.enabled = true;
- transform.localPosition = new Vector3 (PosAntigua.position.x,
- PosAntigua.position.y,
- PosAntigua.position.z);
- transform.localRotation = Quaternion.Euler (-90,0,0);
- }
- }
- public void CogerPergamino () {
- if (!PergaminoTomado) {
- transform.localPosition = new Vector3 (PosNewPergamino.position.x,
- PosNewPergamino.position.y,
- PosNewPergamino.position.z);
- transform.localRotation = Quaternion.Euler (0,0,0);
- transform.SetParent (PosNewPergamino);
- fps.enabled = false;
- StartCoroutine(cogido());
- }
- }
- IEnumerator cogido () {
- yield return new WaitForSeconds (0.00001f);
- transform.localPosition = new Vector3 (0, 0, 0);
- transform.localRotation = Quaternion.Euler (0,0,0);
- transform.localScale = new Vector3 (1, 1, 1);
- PergaminoTomado = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement