MAS EJEMPLOS DE AQUI SE APRENDE.............
----------------------------------------------------------------------------------------------------------------------
PARA ABRIR PUERTAS ....CON UN TAG.......
------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class abresolomalopuertamas : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
//public int Rotador;
void Update () { }
void OnTriggerEnter(Collider other) {
//void OnTriggerEnter(Collider other) {
//if (other.gameObject.CompareTag ("avismo")){
//if (other.gameObject.CompareTag ("ogri2")){
//if (other.gameObject.CompareTag ("molonrobott")){
if (other.gameObject.CompareTag ("malopuerta")){
//}
//var rot = transform.rotation;
//rot.z += Time.deltaTime * 20;
// transform.rotation = rot;
transform.position += transform.right * 361.02f * Time.deltaTime; }
}
}
//}
-----------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
CONTROL DE UN PERSONAJE CON ANIMACION..........
-----------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CONTROLROBOTYO : MonoBehaviour {
// Use this for initialization
//void Start () {
//}
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("ANDA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ANDA", false);
if (Input.GetKey (KeyCode.S)) {
Anim.SetBool ("ATRAS", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ATRAS", false);
if (Input.GetKey (KeyCode.A)) {
Anim.SetBool ("ANDA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ANDA", false);
if (Input.GetKey (KeyCode.D)) {
Anim.SetBool ("ANDA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ANDA", false);
if (Input.GetButtonDown ("Fire1"))
{
//if ((Input.GetButton("Fire1")) {
//if (Input.GetKey (KeyCode.Space)) {
Anim.SetBool ("DISPARO", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("DISPARO", false);
//if (Input.GetButtonUp ("Fire1"))
//{
//if ((Input.GetButton("Fire1")) {
//if (Input.GetKey (KeyCode.Space)) {
//Anim.SetBool ("DISPARO", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
//} else {
//Anim.SetBool ("DISPARO", false);
}
}
}
}
}
}
} //}
-------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
TEMA DISPARO DE OBJETO
-----------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tiroa : MonoBehaviour {
public GameObject tirito;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
//private float nextFire = 0.0f;originallllll
void Update()
{
//if ((Input.GetKey(KeyCode.A) && Time.time > nextFire))//ESTO ES MIO FUNCIONA
//if (Input.GetKey(KeyCode.D) && Time.time > nextFire)//ESTO ES MIO FUNCIONA
if ((Input.GetButton("Fire1") && Time.time > nextFire)) //original ORIGINAL
{
nextFire = Time.time + fireRate;
GameObject clone = Instantiate(tirito, transform.position, transform.rotation) as GameObject;
}
}
}
----------------------------------------------------------------------------------------------------------------
IRE AMPLIANDO EL TEMA CONFORME SIGA APRENDIENDO............TENGO MAS SCRIPTS...LOS IRE PONIENDO ESTOS DIAS.....................................Y PROCURARE EXPLICAR LO MAS PRIMORDIAL DE ELLOS..........
---------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------
ACTIVATE TRIGER......IMPORTANTISIMO CAMBIA OBJETOS AL SER TOCADOS O COLISIONADOS........
----------------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace UnityStandardAssets.Utility
{
public class ActivateTrigger : MonoBehaviour
{
// A multi-purpose script which causes an action to occur when
// a trigger collider is entered.
public enum Mode
{
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate = 5 // Decativate target GameObject
}
public Mode action = Mode.Activate; // The action to accomplish
public Object target; // The game object to affect. If none, the trigger work on this game object
public GameObject source;
public int triggerCount = 1;
public bool repeatTrigger = false;
private void DoActivateTrigger()
{
triggerCount--;
if (triggerCount == 0 || repeatTrigger)
{
Object currentTarget = target ?? gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
{
targetGameObject = targetBehaviour.gameObject;
}
switch (action)
{
case Mode.Trigger:
if (targetGameObject != null)
{
targetGameObject.BroadcastMessage("DoActivateTrigger");
}
break;
case Mode.Replace:
if (source != null)
{
if (targetGameObject != null)
{
Instantiate(source, targetGameObject.transform.position,
targetGameObject.transform.rotation);
DestroyObject(targetGameObject);
}
}
break;
case Mode.Activate:
if (targetGameObject != null)
{
targetGameObject.SetActive(true);
}
break;
case Mode.Enable:
if (targetBehaviour != null)
{
targetBehaviour.enabled = true;
}
break;
case Mode.Animate:
if (targetGameObject != null)
{
targetGameObject.GetComponent<Animation>().Play();
}
break;
case Mode.Deactivate:
if (targetGameObject != null)
{
targetGameObject.SetActive(false);
}
break;
}
}
}
private void OnTriggerEnter(Collider other)
{
DoActivateTrigger();
}
}
}
---------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
MOVER PERSONAJE HUMANOIDE CON SUS ANIMACIONES Y DISPARANDO
-------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class anda : MonoBehaviour {
// Use this for initialization
//void Start () {
//}
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("anda", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("anda", false);
if (Input.GetKey (KeyCode.S)) {
Anim.SetBool ("atras", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("atras", false);
if (Input.GetButtonDown ("Fire1")) {
Anim.SetBool ("dispara", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("dispara", false);
if (Input.GetKey (KeyCode.E)) {
Anim.SetBool ("agacha", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("agacha", false);
}
}
}
}
}
}
---------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
MOVIMIENTOS DE ROTACION
----------------------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
public class AutoMoveAndRotate : MonoBehaviour
{
public Vector3andSpace moveUnitsPerSecond;
public Vector3andSpace rotateDegreesPerSecond;
public bool ignoreTimescale;
private float m_LastRealTime;
private void Start()
{
m_LastRealTime = Time.realtimeSinceStartup;
}
// Update is called once per frame
private void Update()
{
float deltaTime = Time.deltaTime;
if (ignoreTimescale)
{
deltaTime = (Time.realtimeSinceStartup - m_LastRealTime);
m_LastRealTime = Time.realtimeSinceStartup;
}
transform.Translate(moveUnitsPerSecond.value*deltaTime, moveUnitsPerSecond.space);
transform.Rotate(rotateDegreesPerSecond.value*deltaTime, moveUnitsPerSecond.space);
}
[Serializable]
public class Vector3andSpace
{
public Vector3 value;
public Space space = Space.Self;
}
}
}
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
CONTADOR....MARCADOR DE PUNTUACION.....ENTES CASO ASTA 51 DE REFERENCIA....
----------------------------------------------------------------------------------------------------------------
using UnityEngine;
// Include the namespace required to use Unity UI
using UnityEngine.UI;
using System.Collections;
public class bapuntos51 : MonoBehaviour {
// Create public variables for player speed, and for the Text UI game objects
public float speed;
public Text countText;
public Text winText;
//public AudioSource tickSource;
//public AudioSource tickSource;
// Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
private Rigidbody rb;
private int count;/// <summary>
/// //////////////////////////////////////////
/// </summary>
//private int PUNTOS;/// <summary>
/// /////////////////////////////////////////////////
/// </summary>
// At the start of the game..
void Start ()
{
//tickSource = GetComponent<AudioSource> ();
//tickSource = Getcomponent<AudioSource> ();
// Assign the Rigidbody component to our private rb variable
rb = GetComponent<Rigidbody>();
// Set the count to zero
count = 0;
// Run the SetCountText function to update the UI (see below)
SetCountText ();
// Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
winText.text = "";
}
// Each physics step..
//void FixedUpdate ()
//{
// Set some local float variables equal to the value of our Horizontal and Vertical Inputs
//float moveHorizontal = Input.GetAxis ("Horizontal");
//float moveVertical = Input.GetAxis ("Vertical");
// Create a Vector3 variable, and assign X and Z to feature our horizontal and vertical float variables above
//Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
// Add a physical force to our Player rigidbody using our 'movement' Vector3 above,
// multiplying it by 'speed' - our public player speed that appears in the inspector
// rb.AddForce (movement * speed);
//}
// When this game object intersects a collider with 'is trigger' checked,
// store a reference to that collider in a variable named 'other'..
void OnTriggerEnter(Collider other)
{
// ..and if the game object we intersect has the tag 'Pick Up' assigned to it..
//if (other.gameObject.CompareTag ("pruebassonido"))
//if (other.gameObject.CompareTag ("bolaesplota"))
if (other.gameObject.CompareTag ("ARAÑA-3-ESTE"))
//if (other.gameObject.CompareTag ("Terrain"))
//if (other.gameObject.CompareTag ("Pick Up 1"))
//if (other.gameObject.CompareTag ("Sphere"))
{
// Make the other game object (the pick up) inactive, to make it disappear
other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add one to the score variable 'count'
count = count + 1;
//tickSource.Play ();
// Run the 'SetCountText()' function (see below)
SetCountText ();
}
}
// Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
void SetCountText()
{
// Update the text field of our 'countText' variable
//countText.text = "Count: " + count.ToString ();
countText.text = "PUNTOS: " + count.ToString ();
// Check if our 'count' is equal to or exceeded 12
if (count >= 11)
//if (count >= 99)
{
// Set the text value of our 'winText'
winText.text = "JUEGO COMPLETADO";
//TextMeshPro = "CAMPEON GANASTES";
Destroy (gameObject, 1.2f);
//transform.position += transform.forward * 210.222f * Time.deltaTime; ///////etste solo
//transform.position += transform.forward *110.02f * Time.deltaTime;
//transform.position -= transform.forward *8.02f * Time.deltaTime;
//transform.Rotate (new Vector3 (12 * Time.deltaTime, 220, 290), Space.Self);
//Destroy (gameObject, 0.2f);
//transform.localScale += Vector3.right * 444 * Time.deltaTime;//OJOJOJOJOJOJOJOJOJO
//Destroy (gameObject, 0.2f);
//transform.Rotate(10, Time.deltaTime, 100, Space.World);
}
}
}
------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
BORRA UN OBJETO LO DESTRUYE......CON UN TAG NOMBRE CONCRETO A ESE TAG......
-----------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
public class borraconprojectile : MonoBehaviour {
//public float Destroy = 0.2f;
// Use this for initialization
void Start () {
}
//void OnCollisionEnter (){
void OnCollisionEnter (Collision collision)
{
//if (collision.gameObject.tag == "maloazul (4)") {
//Destroy (gameObject, 0.0f);
if (collision.gameObject.tag == "Projectile") {
Destroy (gameObject, 0.0f);
}
}
}
------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
BORRA UN OBJETOS POR TIEMPO----AL SER COLISIONADO
-------------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class borracubo5segundos : MonoBehaviour {
public float Destroy = 10.01f;
// Use this for initialization
void Start () {
}
void OnCollisionEnter (){
Destroy (gameObject, 10.01f);
}
}
-------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
UNA MANERA DE BORRAR TEXTO POR EJEMPLO EL TITULO DE UN JUEGO POCO ANTES DE EMPEZAR A JUGAR
-------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class borramitexto : MonoBehaviour {
// Use this for initialization
void Start () {
}
void Update ()
{
if (Input.GetKey(KeyCode.W))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.Space))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.S))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.A))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.D))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.Q))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.E))
//void OnCollisionEnter (){
Destroy (gameObject, 0.00f);
if (Input.GetKey(KeyCode.KeypadEnter))/////ENTER DEL TECLADO NUMERICO IGNORO MOTIBO
Destroy (gameObject, 0.00f);
}
}
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
EJEMPLO DE CONTROL DE HUMANOIDE POR TECLADO Y ASIGNACION DE ANIMACIONES.....
-------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CONTROLHUMANO : MonoBehaviour {
// Use this for initialization
//void Start () {
//}
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("Walking", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("Walking", false);
}
}
}
--------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
MOVIMIENTOS GIRATORIOS
---------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class girabaile : MonoBehaviour {
// Use this for initialization
void Start () {
//transform.rotation = Quaternion.Euler (0,45, 0);
}
// Update is called once per frame
void Update () {
// Es la rotacion de Angulos de Euler en grados.
transform.Rotate (new Vector3 (0 * Time.deltaTime, 1, 0), Space.Self);
}
}
------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
EJEMPLO PARA GIRAR ROTAR UN TEXTO........
----------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jiratexto : MonoBehaviour {
// Use this for initialization
void Start () {
//transform.rotation = Quaternion.Euler (0,45, 0);
}
// Update is called once per frame
void Update () {
// Es la rotacion de Angulos de Euler en grados.
transform.Rotate (new Vector3 (0 * Time.deltaTime, 0.3f, 0), Space.Self);
}
}
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
CONTINUARE AMPLIANDO LA PAGINA.........19-09-2020.....ASTA PRONTO......
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
UNA MANERA DE ABRIR PUERTAS
-----------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class abresolomalopuertamas : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
//public int Rotador;
void Update () { }
void OnTriggerEnter(Collider other) {
//void OnTriggerEnter(Collider other) {
//if (other.gameObject.CompareTag ("avismo")){
//if (other.gameObject.CompareTag ("ogri2")){
//if (other.gameObject.CompareTag ("molonrobott")){
if (other.gameObject.CompareTag ("malopuerta")){
//}
//var rot = transform.rotation;
//rot.z += Time.deltaTime * 20;
// transform.rotation = rot;
transform.position += transform.right * 361.02f * Time.deltaTime; }
}
}
//}
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
DESTRUCCION
-----------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class destruyeportac : MonoBehaviour {
//public AudioSource tickSource;
void Start () {
//tickSource = GetComponent<AudioSource> ();
}
void Update () {
}
void OnTriggerEnter(Collider other) {
//if (other.gameObject.CompareTag ("avismo")){
//if (other.gameObject.CompareTag ("ogri2")){
if (other.gameObject.CompareTag ("MATA")){
//transform.Rotate (new Vector3 (0 * Time.deltaTime, 91, 90), Space.Self);
//tickSource.Play ();
Destroy (gameObject, 0.0f);
}}
}
//}
---------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
----------PARA CAMBIAR DE NIVEL AL APRETAR UNA TECLA TECLADO DEL PC......EN ESTE CASO " Esc"
----------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tocateclaycambianivel : MonoBehaviour {
// Use this for initialization
void Start () {
}
void Update ()
{
//if (Input.GetKey(KeyCode.P))
if (Input.GetKey(KeyCode.Escape ))
//void OnCollisionEnter (){
//Destroy (gameObject, 0.00f);
Application.LoadLevel (0);
}
}
----------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
MOVIMIENTO DE UN OBJETO
----------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class muebelado : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position += transform.forward * 10.2f * Time.deltaTime; }
}
----------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
ControladorDelJugador
------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ControladorDelJugador : MonoBehaviour
{
public float velocidad;
public Text marcador;
public Text terminaste;
Rigidbody rb;
int contador;
void Awake()
{
rb = GetComponent<Rigidbody>();
contador = 0;
ActualizarMarcador();
terminaste.gameObject.SetActive(false);
}
void FixedUpdate()
{
float movimientoHorizontal = Input.GetAxis("Horizontal");
float movimientoVertical = Input.GetAxis("Vertical");
Vector3 movimiento = new Vector3(movimientoHorizontal, 0f, movimientoVertical);
rb.AddForce(movimiento * velocidad);
}
void OnTriggerEnter(Collider other)
{
Destroy(other.gameObject);
contador = contador + 1;
ActualizarMarcador();
if(contador >= 13)
{
terminaste.gameObject.SetActive(true);
}
}
void ActualizarMarcador()
{
marcador.text = "Puntos: " + contador;
}
}
---------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
AutoMoveAndRotate
------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
public class AutoMoveAndRotate : MonoBehaviour
{
public Vector3andSpace moveUnitsPerSecond;
public Vector3andSpace rotateDegreesPerSecond;
public bool ignoreTimescale;
private float m_LastRealTime;
private void Start()
{
m_LastRealTime = Time.realtimeSinceStartup;
}
// Update is called once per frame
private void Update()
{
float deltaTime = Time.deltaTime;
if (ignoreTimescale)
{
deltaTime = (Time.realtimeSinceStartup - m_LastRealTime);
m_LastRealTime = Time.realtimeSinceStartup;
}
transform.Translate(moveUnitsPerSecond.value*deltaTime, moveUnitsPerSecond.space);
transform.Rotate(rotateDegreesPerSecond.value*deltaTime, moveUnitsPerSecond.space);
}
[Serializable]
public class Vector3andSpace
{
public Vector3 value;
public Space space = Space.Self;
}
}
}
------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------
--------------------------------------------------------TIROSS
------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TIROSS : MonoBehaviour {
public GameObject tirito;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
//private float nextFire = 0.0f;originallllll
void Update()
{
if ((Input.GetKey(KeyCode.S) && Time.time > nextFire))//ESTO ES MIO FUNCIONA
//if (Input.GetKey(KeyCode.D) && Time.time > nextFire)//ESTO ES MIO FUNCIONA
//if (Input.GetButton("Fire1") && Time.time > nextFire) //original ORIGINAL
{
nextFire = Time.time + fireRate;
GameObject clone = Instantiate(tirito, transform.position, transform.rotation) as GameObject;
}
}
}
----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
tiros
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tiros : MonoBehaviour {
public GameObject tirito;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
//private float nextFire = 0.0f;originallllll
void Update()
{
if (Input.GetKey(KeyCode.W) && Time.time > nextFire)//ESTO ES MIO FUNCIONA
//if (Input.GetButton("Fire1") && Time.time > nextFire) //original ORIGINAL
{
nextFire = Time.time + fireRate;
GameObject clone = Instantiate(tirito, transform.position, transform.rotation) as GameObject;
}
}
}
-----------------------------------------------------------------------------------------------------------------------
CONTROLHUMANO
EN EL VIDEO EXPLICO SOBRE EL SCRIPT
------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CONTROLHUMANO : MonoBehaviour {
// Use this for initialization
//void Start () {
//}
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("Walking", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("Walking", false);
}
}
}
-------------------------------------------------------------------------------------------------------------------------
todoslosmovimientosplayer
--------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class todoslosmovimientosplayer : MonoBehaviour {
//public float moveSpeed = 180f;
//public float turnSpeed = 100f;
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("anda", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("anda", false);
if (Input.GetKey (KeyCode.S)) {
Anim.SetBool ("atras", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("atras", false);
if (Input.GetKey (KeyCode.Q)) {
Anim.SetBool ("corre", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("corre", false);
if (Input.GetKey (KeyCode.E)) {
Anim.SetBool ("stop", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("stop", false);
if (Input.GetKey (KeyCode.L)) {
Anim.SetBool ("enpie", true);
//transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("enpie", false);
}
}
}
}
}
}
}
-------------------------------------------------------------------------------------------------------------------
NUEVOS SCRIPTS 10-10-22
--------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BORRAPUERTASQUITASALPASARLASEIS : MonoBehaviour
{
public GameObject puertagiratoriadesdeblenderSEIS;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
puertagiratoriadesdeblenderSEIS.SetActive(false);
}
}
private void OnTriggerExit(Collider other)/////imbento
{
if (other.tag == "Player")///////imbento
{
puertagiratoriadesdeblenderSEIS.SetActive(true);
}
}
}
--------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BORRAPUERTASQUIETASALPASAR : MonoBehaviour
{
public GameObject puertagiratoriadesdeblenderCINCO;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
puertagiratoriadesdeblenderCINCO.SetActive(false);
}
}
private void OnTriggerExit(Collider other)/////imbento
{
if (other.tag == "Player")///////imbento
{
puertagiratoriadesdeblenderCINCO.SetActive(true);
}
}
}
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class activatTexto : MonoBehaviour
{
public GameObject texto;
private void OnTriggerEnter (Collider other)
{
if(other.tag == "Player")
{
texto.SetActive(true);
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
texto.SetActive(false);
}
}
}
-------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class creaenmano3 : MonoBehaviour
{
public GameObject retra, pico;
// private void Update()/////original
// {/////////////////original
// if (Input.GetKeyDown(KeyCode.Alpha1))/////original
// {////original
// hacha.SetActive(false);///original
// pico.SetActive(false);/////original
// }////original
private void OnTriggerEnter(Collider other)/////imbento
{
if (other.tag == "Player")///////imbento
{/////////////////////////////////////imbento
// if (Input.GetKeyDown(KeyCode.Alpha2))//////original
{
retra.SetActive(true);
pico.SetActive(false);
}
// if (Input.GetKeyDown(KeyCode.Alpha3))
// {
// hacha.SetActive(false);
// pico.SetActive(true);
}
}
}
// }///////////////////imbento
--------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class VARRAMENGUAYVAALCERONIVEL1 : MonoBehaviour
{
// public int cura;
public int damage;
//public int dumugu;//imbento
public int vidaEnemigo;
//public int vidaEnemigo2;//imbento
public Slider BarraVidaEnemigo;
void Update()
{
BarraVidaEnemigo.value = vidaEnemigo;
}
void OnTriggerEnter(Collider other)
{
//if (other.gameObject.CompareTag ("MATA")){
if (other.gameObject.CompareTag("pipi"))
{
vidaEnemigo -= damage;
if (vidaEnemigo <= 0)
{
//if (Input.GetButton("Fire3"))////// AMETRALLADORA AMETRAYADORA imbentooo
//void OnTriggerEnter(Collider other)///imbento
//{///imbento
// if (other.gameObject.CompareTag("cici"))////imbento
//{////imbento
//vidaEnemigo += dumugu;////imbento
// if (vidaEnemigo <= 0)/////imbento
//{// imbento
//Application.LoadLevel (3);////original 16-6-22
//Application.LoadLevel (10); ////prueba ORIGINAL DE 22-6-22
// Application.LoadLevel (1); ////prueba
Application.LoadLevel(0); ////prueba ORIGINAL DE 26-7-22///////////////////////original
}
}
}
}
//}///imbento
//}////imbento
--------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class boyademo : MonoBehaviour
{
public Text contador1;
public Text fin1;
//private float tiempo = 120f;
private float tiempo = 80f;
// Use this for initialization
void Start()
{
contador1.text = " " + tiempo;
fin1.enabled = false;
}
// Update is called once per frame
void Update()
{
tiempo -= Time.deltaTime;
contador1.text = " " + tiempo.ToString("f0");
if (tiempo <= 0)
{
contador1.text = "0";
fin1.enabled = true;
{
//void OnTriggerEnter(Collider other) {
//if (other.gameObject.CompareTag ("ogri2 (1)CAMPEONNNNNNNNNNNNNNNNNNN")){
Destroy(gameObject, 0.0f);
{
//Application.LoadLevel (1); ESTE ES EL ORIGINALLLLLLL
Application.LoadLevel(1);
}
}
}
}
}
-----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class creaenmano3 : MonoBehaviour
{
public GameObject retra, pico;
// private void Update()/////original
// {/////////////////original
// if (Input.GetKeyDown(KeyCode.Alpha1))/////original
// {////original
// hacha.SetActive(false);///original
// pico.SetActive(false);/////original
// }////original
private void OnTriggerEnter(Collider other)/////imbento
{
if (other.tag == "Player")///////imbento
{/////////////////////////////////////imbento
// if (Input.GetKeyDown(KeyCode.Alpha2))//////original
{
retra.SetActive(true);
pico.SetActive(false);
}
// if (Input.GetKeyDown(KeyCode.Alpha3))
// {
// hacha.SetActive(false);
// pico.SetActive(true);
}
}
}
// }///////////////////imbento
----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class destruyemetraportag : MonoBehaviour
{
//public AudioSource tickSource;
void Start()
{
//tickSource = GetComponent<AudioSource> ();
}
void Update()
{
}
void OnTriggerEnter(Collider other)
{
//if (other.gameObject.CompareTag ("avismo")){
//if (other.gameObject.CompareTag ("ogri2")){
if (other.gameObject.CompareTag("Player"))
{
//transform.Rotate (new Vector3 (0 * Time.deltaTime, 91, 90), Space.Self);
//tickSource.Play ();
Destroy(gameObject, 0.0f);
}
}
}
//}
-------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DISPARAMUCHOVELOZ : MonoBehaviour
{
public Transform player;
// public float range = 1f;
//public float range = 4f;
public float range = 0.04f;
public float bulletImpulse = 0.1f;
private bool onRange = false;
public Rigidbody projectile;
void Start()
{
//float rand = Random.Range(1.0f, 2.0f);/////ORIGINAL
//float rand = Random.Range(0.04f, 2.0f);/////tambien funciona///////////////////////////EL QUE VENGO USANDO
float rand = Random.Range(0.04f, 0.5f);/////tambien funciona METRALLADORA MAS LENTA
//float rand = Random.Range(0.04f, 0.08f);/////tambien funciona////METRALLADORA
InvokeRepeating("Shoot", 2, rand);//////ORIGINAL
}
void Shoot()
{
if (onRange)
{
Rigidbody bullet = (Rigidbody)Instantiate(projectile, transform.position + transform.forward, transform.rotation);
bullet.AddForce(transform.forward * bulletImpulse, ForceMode.Impulse);
Destroy(bullet.gameObject, 2);
}
}
void Update()
{
onRange = Vector3.Distance(transform.position, player.position) < range;
if (onRange)
transform.LookAt(player);
}
}
-----------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DISPARATIRITO : MonoBehaviour {
public Transform player;
// public float range = 1f;
//public float range = 4f;
public float range = 0.04f;
public float bulletImpulse = 0.1f;
private bool onRange = false;
public Rigidbody projectile;
void Start()
{
float rand = Random.Range(1.0f, 2.0f);/////ORIGINAL
//float rand = Random.Range(0.04f, 2.0f);/////tambien funciona///////////////////////////EL QUE VENGO USANDO
//float rand = Random.Range(0.04f, 0.5f);/////tambien funciona
//float rand = Random.Range(0.04f, 0.08f);/////tambien funciona
InvokeRepeating("Shoot", 2, rand);//////ORIGINAL
}
void Shoot()
{
if (onRange)
{
Rigidbody bullet = (Rigidbody)Instantiate(projectile, transform.position + transform.forward, transform.rotation);
bullet.AddForce(transform.forward * bulletImpulse, ForceMode.Impulse);
Destroy(bullet.gameObject, 2);
}
}
void Update()
{
onRange = Vector3.Distance(transform.position, player.position) < range;
if (onRange)
transform.LookAt(player);
}
}
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FOGONAZOENEMIGO : MonoBehaviour {
public Transform player;
// public float range = 1f;
//public float range = 4f;
public float range = 0.04f;
public float bulletImpulse = 0.1f;
private bool onRange = false;
public Rigidbody projectile;
void Start()
{
float rand = Random.Range(1.0f, 2.0f);/////ORIGINAL
//float rand = Random.Range(0.04f, 2.0f);/////tambien funciona///////////////////////////EL QUE VENGO USANDO
//float rand = Random.Range(0.04f, 0.5f);/////tambien funciona
//float rand = Random.Range(0.04f, 0.08f);/////tambien funciona
InvokeRepeating("Shoot", 2, rand);//////ORIGINAL
}
void Shoot()
{
if (onRange)
{
Rigidbody bullet = (Rigidbody)Instantiate(projectile, transform.position + transform.forward, transform.rotation);
bullet.AddForce(transform.forward * bulletImpulse, ForceMode.Impulse);
Destroy(bullet.gameObject, 2);
}
}
void Update()
{
onRange = Vector3.Distance(transform.position, player.position) < range;
if (onRange)
transform.LookAt(player);
}
}
No hay comentarios:
Publicar un comentario