Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - ramunda

#41
Hola buenas tardes, me esta pasando una cosa rara que no me habia pasado antes y no se por que...Estoy en nivel 1, paso a nivel 2, y los bichos no se mueven,Si cargo la escena individualmente va perfecto pero si llego a ella desde el otro nivel estaticos. Uso este script muyy simple para pasar de nivel: 
using UnityEngine;
using System.Collections;

public class cambiodelevel : MonoBehaviour {

//public static function DontDestroyOnLoad( Object target  ): void;
public  GameObject player;
void OnTriggerEnter (){
 Application.LoadLevel ("Gluta");
}
void Awake() {
DontDestroyOnLoad(transform.gameObject);
}
}
Alguna idea?.Gracias 
#42
General (Antiguo) / Colision con enemigo
Agosto 22, 2015, 11:45:52 PM
Hola muy buenas a ver si me podéis dar algún consejo o referencia de como hacer que se active la sangre al darle a un enemigo con un cuchillo.Explico, tengo un gameobject que es una sparcle(un salpicon de sangre),añadida a mi arma un cuchillo en este caso,.La cual solo quiero que se active cuendo el cuchillo toca el enemigo y le daña(eso va bien le pose un Debug.log), pero no consigo la formula.Probe asi: 
using UnityEngine;
using System.Collections;
public class sangre : MonoBehaviour {
public GameObject sangre2;


void OnCollisionEnter ( Collision collider  ){
if(collider.gameObject.tag == "cuchillo")
{
sangre2.SetActive(true);
}
else
{
sangre2.SetActive(false);
}
}
}
 este script esta en el enemigo lleva su box collitder y todo eso.básicamente le digo que cuando colisione(el enemigo), con mi cuchillo(tag:cuchillo), se active el gameobject(sangre2), que ya le he proporcionado en el inspector.Pero no se activan.....Alguna sugerencia o idea por favor?Gracias de antemano.     
#43
General (Antiguo) / Doble Disparo
Agosto 03, 2015, 03:07:36 PM
Hola muy buenas aver si me podeis dar algun consejo o referencia de como hacer disparar 2 gameobjects con una bala con rigidbodi al apretar el boton de el mouse.La cosa es que tengo una nave simple que lleva 2 cañones uno en cada ala.E creado un script que va bien y dispara una especie de laser verde , este script esta añadido a un Empty con un Rigid Body.Bien , si clono dicho GO y lo pongo en la segundo cañon ...deberia disparar igual que el primero...pero no ...sale una cosa rara que no es el rayo.Aver si teneis alguna sujerencia de porque no disparan los dos a la vez.A , he probado a ponerle que el segundo cañon dispare en vez de con el boton 1 de el raton con el 2 y funciona pero claro me implica tener los 2 botones ocupados para 1 disparo.El script:
using UnityEngine;
using System.Collections;
public class disparosyrecargosnave : MonoBehaviour {
public Rigidbody Bala;
public float Velocidad = 80;
public float municion = 10;
public Animation reload;
float municionderecargo = 10;
public float municiontotal = 200;
///public static float municiontotal = 150;
public disparosyrecargos2 MyScriptShoot;
public float Conteo = 0;
public GUIText guimuni;
public GUIText guitotal;
public GameObject destello;
//public GameObject manoanim;
public GameObject expulsabalas;
public AudioClip recarga;
public AudioClip gunShot;
public AudioClip vacio;
//bool DisparoDual = true;

void Start (){

destello.active = false;
}

void Update (){

guimuni.text = "Balas " + municion.ToString();
guitotal.text = "Total Balas " + municiontotal.ToString();

   if (Input.GetButton("Fire1"))
   {
//if(Input.GetMouseButtonDown(0)){   
        Conteo = Conteo + 1;
       
    if(Conteo > 15){
    
     Conteo = 0;
}   
    if(Conteo == 15 && municion > 0 && municiontotal >= 0){
          
        
   Rigidbody clone;
   clone=Instantiate(Bala, transform.position, transform.rotation) as Rigidbody;
   clone.velocity = transform.TransformDirection(Vector3.forward * 400);
   municion -= 1;
         Destroy (clone,1.0f);
   GetComponent<AudioSource>().PlayOneShot(gunShot);
   
}
}
if(Input.GetKeyDown("r") && municiontotal > 0 && !Input.GetMouseButton(0) && !Input.GetMouseButton(1)){
reload.Play("pistolamueve");
municion = 0;
Invoke ("recargando",2);
    AudioSource.PlayClipAtPoint(recarga, transform.position, 1);
 
}

   if(Input.GetButton("Fire1")){

destello.active = true;
}
else
if(Input.GetMouseButtonUp(0)){
destello.active = false;
}   
if (municion <= 0){
if(Input.GetButton("Fire1")){
expulsabalas.SetActive(false);
AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = false;
}   
}
}
void recargando (){


expulsabalas.SetActive(true);
if(municiontotal > 0){
municiontotal -= municionderecargo;
municion += municionderecargo;

}
if (municion > municionderecargo){
municion = municionderecargo;
}
}
}
  
#44
General (Antiguo) / Pausa entre ataques...
Julio 30, 2015, 07:31:04 PM
Hola muy buenas,tengo este script a un enemigo eskeleto el cual funciona ...pero no muy bien, si me vee en un rango de 50 me persigue y me ataca, eso va bien pero la cosa esque me daña a 1000 revoluciones por segundo....me hace 30 de daño:character.ApplyDamage(30); pero a velocidad rayo!!!he intentado ponerle una pausa o relentizar el tiempo de el ataque con un yield wait for seconds, pero lo de la coorutina o como se llame no hay manera de colocarsela. el script es cortito:
using UnityEngine;
using System.Collections;
public class skellyattack : MonoBehaviour {
public GameObject player;
public GameObject skelly;
public float distance;
//private int damage =10;
public PlayerInfo character;
private float timer = 5f;
   
   // Use this for initialization
   void Start () {

}

   
   // Update is called once per frame
   void Update () {

      
   player = GameObject.FindWithTag("jugador");
   skelly = gameObject;
   distance = Vector3.Distance(player.transform.position,skelly.transform.position);
   if (distance <= 3) {
   skelly.GetComponent<Animation>().CrossFadeQueued("Run", 0.3f, QueueMode.PlayNow);
   skelly.GetComponent<Animation>().CrossFade("SwingHeavy");
         

      character.playerInCombat(true);
      character.ApplyDamage(30);
      }
      else if (distance < 45 && distance > 3.0f) {
      skelly.GetComponent<Animation>().CrossFadeQueued("SwingHeavy", 0.3f, QueueMode.PlayNow);
      skelly.GetComponent<Animation>().CrossFade("Run");
      skelly.transform.LookAt(player.transform.position);
      transform.position = Vector3.MoveTowards(transform.position, player.transform.position, 0.15f);
      //character.playerInCombat(true);
         
      }   
      else
      //GetComponent<FollowPath>().enabled = true;
      {
      skelly.GetComponent<Animation>().CrossFadeQueued("Run", 0.3f, QueueMode.PlayNow);
      skelly.GetComponent<Animation>().CrossFade("IdleHoldSword");
      //character.playerInCombat(true);
      }
   }
   
   
}
en la linea 26 es donde hace el ataque ...le puse el return yeld waitforseconds y me manda al carajo XDD Alguna idea por favor de donde o como poner la coorutina? Gracias!!!   
#45
General (Antiguo) / Restar vida a jugador
Julio 29, 2015, 02:14:49 PM
Hola muy buenas, tengo una duda que no se porque no me deja este script a añadirle un gameobjecr.Explico tengo una bala enemiga que colisiona con mi jugador y lo que quiero es que me reste vida y llamo al script que tiene el sistema de vida pero no me hace daño:Script de sistema de vida(que funciona bien menos con la bala)
using UnityEngine;
using System.Collections;

public class PlayerInfo : MonoBehaviour {
public GameObject Bocaarma;
public GameObject healthBottle;
public GameObject player;
public AudioClip deathClip;
public AudioClip deathClip2;
public AudioSource sonido;
public AudioSource sonido2;
public GameObject sonidoisladino;
public GameObject sonidoaguadino2;
public GameObject sonidoaguadino1;
public GameObject sonidoaguadino3;
public GameObject sonidoaguadino4;
public GameObject sonidoaguadino5;
public GameObject sonidoaguadino6;
public GameObject sonidoaguadino7;
public GameObject cave1;
public Animation muerto2;
public float length;

public int Xmin = 400;
public int Xmax = 700;
public int Ymin = 300;
public int Ymax = 800;
//public AnimationClip Die;

int health = 100;
int damageCount = 0;
int currentHealth;
bool playerFighting;
public GUIText healthbar;
float timer = 0.0f;
float healthTimer = 0.0f;
bool healthShouldRespawn = false;

public bool muerto = false;
public GameObject tuUI;

void Start () {
   currentHealth = health;
   tuUI.SetActive(false);
   }

void Update () {
   Cursor.visible = false;
   print("player in combat? " + playerFighting);
   if(!playerFighting){
      print("player is not fighting");
      if(currentHealth != 100){
         timer += Time.deltaTime;
         print ("timer: " + timer);
         if(timer > 90.0f){
            currentHealth += 10;
            timer = 0.0f;
         }
      }
   }
   else
   {
      if(currentHealth <= 0 && !muerto ){
         muerto = true;
         sonido.PlayOneShot(deathClip2);
         muerto2.Play("muerto");
         //GetComponent<AudioSource>().enabled = false;
         //GetComponent<AudioSource>().PlayOneShot(deathClip2);//length =5f;
         GetComponent<FPSInputController>().enabled = false;
         GetComponent<CharacterController>().enabled = false;
         Bocaarma.SetActive(false);
         sonidoisladino.SetActive(false);
         sonidoaguadino2.SetActive(false);
         sonidoaguadino3.SetActive(false);
         sonidoaguadino4.SetActive(false);
         sonidoaguadino5.SetActive(false);
         sonidoaguadino6.SetActive(false);
         sonidoaguadino7.SetActive(false);
         sonidoaguadino1.SetActive(false);
         cave1.GetComponent<AudioSource>().enabled = false;
      

         
         //Destroy(gameObject);


   
      }
   }
   healthbar.text = "Vida " + currentHealth + " / 100";
   
   if(healthShouldRespawn)
   {
      healthTimer += Time.deltaTime;
      
      if(healthTimer > 5.0f)
      {
         healthBottle.gameObject.SetActive(true);
         healthTimer = 0.0f;
      }
   }
   
   if(muerto){
      //var anim = GetComponent<Animation>();
      //anim.AddClip(Die,"attackbo");
      //anim.play("attackbo");
      //GetComponent<AudioSource>().PlayOneShot(deathClip2);length =5f;
      Cursor.visible = false;
      tuUI.SetActive(true);
      if(Input.GetKeyDown(KeyCode.Space)){
         Respawn();
      }
   }
   
}

public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      if(currentHealth < 0){
         currentHealth = 0;
      }
      currentHealth = currentHealth - 30;
      sonido2.PlayOneShot(deathClip);
      //GetComponent<AudioSource>().PlayOneShot(deathClip);
      //GetComponent<AudioSource>().PlayOneShot(deathClip);//length =3f;
      healthbar.text = "Health " + currentHealth + " / 100";
      damageCount = 0;
   }
   
   print(currentHealth);
}

public void playerInCombat(int combat){
   if(combat == 1){
      playerFighting = true;
   }
   else
   {
      playerFighting = false;
   }
}

public void Respawn(){
   tuUI.SetActive(false);
   muerto = false;
   transform.position = new Vector3(Random.Range(Xmin, Xmax),0, Random.Range(Ymin, Ymax));
   //transform.position = new Vector3(Random.Range(400.0f, 700.0f), 0, Random.Range(300.0f, 800.0f));
   GetComponent<FPSInputController>().enabled = true;
   GetComponent<CharacterController>().enabled = true;
   sonidoisladino.SetActive(true);
   sonidoaguadino2.SetActive(true);
   sonidoaguadino3.SetActive(true);
   sonidoaguadino4.SetActive(true);
   sonidoaguadino5.SetActive(true);
   sonidoaguadino6.SetActive(true);
   sonidoaguadino7.SetActive(true);
   sonidoaguadino1.SetActive(true);
   cave1.GetComponent<AudioSource>().enabled = true;
   ///GetComponent<AudioSource>().enabled = true;
   //GetComponent<disparosyrecargos2>().enabled = true;
   ////GetComponent<MouseLook>().enabled = true;
   Bocaarma.SetActive(true);
   currentHealth = 100;
}

void OnTriggerEnter(Collider item){
   if(item.gameObject.tag == "PlayerHealthBottle")
   {
      if(currentHealth < 100)
      {
         currentHealth = currentHealth + 50;
         item.gameObject.SetActive(false);
         healthShouldRespawn = false;
      }
   }
}
}
Lineas desde la 117 a la 128 es donde al recibir daño ejecute su función.son estas: 
public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      if(currentHealth < 0){
         currentHealth = 0;
      }
      currentHealth = currentHealth - 30;
bien eso esta claro. Ahora el de la bala:
using UnityEngine;
using System.Collections;
public class Dañodebala : MonoBehaviour {
public PlayerInfo character;
float Dano = 150;

void OnCollisionEnter


( Collision info  ){
info.transform.SendMessage("ApplyDammage", Dano, SendMessageOptions.DontRequireReceiver);
}
}
 le digo que si entra en contacto con el "jugador" le aplique el daño XXXXarriba le defino el public PlayerInfo que es donde están las variables de vida.(el script primero de arriba).Bien pues la bala impacta con mi jugador, en mi capsule collider, pero no me resta vida. No se si me explico muy bien...pero mas o menos es eso.Y no se porque!! no me hace daño, alguna idea por favor?  
#46
General (Antiguo) / Torreta que gira mal
Julio 28, 2015, 05:56:29 PM
Hola muy buenas ya estoy de nuevo por aqui :),Sere breve Tengo una torreta muy molona la cual me dispara si estoy en el rango que quiero con este script que le puse:(lo dejo por si a alguien mas le sirve)
using UnityEngine;
using System.Collections;

public class enemigoataca : MonoBehaviour {

public Transform player;
public float range = 50.0f;
public float bulletImpulse= 70.0f;

private bool onRange= false;

public Rigidbody projectile;

void Start(){
   float rand = Random.Range (1.0f, 2.0f);
   InvokeRepeating("Shoot", 1, rand);
}

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);
}


}
Bien esto se pone en un Empty GO y se pone el el cañon de la metralleta o lo que sea y dispara.Bien ahora la Torreta:es esta de la foto, bien el problema es que ponga donde le ponga este scrip que a continuación pondre la torreta se gira hacia mi(jugador), si pero qde que manera da mas vueltas que una peonza arriba abajo, de da la vuelta de queda de lado etc....lo que no encuentro es la manera de que solo se gire circularmente osea dando la vuelta no que se ponga bocabajo o bocarriba.... El script que tengo en ella:
using UnityEngine;
using System.Collections;

public class TurretScript: MonoBehaviour
{

public Transform Target;
public float RotationSpeed;

void Update()
{
   var direction = Target.transform.position - transform.position;
   
   direction.y = transform.position.y;
   
   var rot = Quaternion.LookRotation(direction, Vector3.up);      
   transform.rotation = Quaternion.RotateTowards(
      transform.rotation,
      rot,
      RotationSpeed * Time.deltaTime);
}
}
Agradeceria una ayudaita , muchas gracias de antemano!!!P.D, tampoco veo la manera de que dispare mas rapido...con la fuerza lo unico que consigo es que corra mas rapido la bala no el tiempo de disparo.  
#47
General (Antiguo) / Enemigos que cruzan paredes...
Julio 24, 2015, 10:41:24 PM
Hola muy buenas , tengo una duda y no encuentro la solución , tengo una serie de enemigos, varios en general todos tienen sphere collither para que las balas los maten , no estan en trigguer, tienen rigidbody, y todo ok . Pero por ejemplo edificios con un mesh collither , lo cruzan cuando vienen a mi a atacarme o ***guirme etc.alguna solución para que no crucen los mesh?, mi personaje no los cruza ellos si.... Gracias  
#48
Hola buenas tardes, se me escapa algo y no se que es he mirado foros y tutos y sigue sin funcionar.Sere breve i explicito.Una trampilla con tag "trapdoor",con un collider que te lleva a un nuevo level con script:
#pragma strict
 var player : GameObject;
 function OnTriggerEnter() {
  Application.LoadLevel ("gruta");
 }
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
en el otro nivel un simple cubo con un collider y este script:
using UnityEngine;
using System.Collections;

public class teleportspawnpoint : MonoBehaviour {
public GameObject player;//que el jugador sea el que se mueva.


void OnTriggerEnter(Collider other)
{

   if(other.gameObject.tag == "jugador")

   {
      DontDestroyOnLoad(other.gameObject);//que se lleve el objeto al otro level.
      Application.LoadLevel("laisla");//carga nivel 1(laisla).
   }
}
void OnLevelWasLoaded(int thisLevel)
{
   player.transform.position = GameObject.FindWithTag("trapdoor").transform.position;//le digo que al cargar el lvl busque este objeto y vaya hacia el.
   
}
}
Y no hay manera de que me aparezca el la trampilla se va al comienzo de donde empieza el nivel 1. Alguna idea de que esta mal?Gracias de antemano. 
#49
General (Antiguo) / borrar los playerpref?¿
Julio 23, 2015, 09:56:18 AM
La cosa es que cree una estatua que al pasar sobre ella se me crea como un "Checkpoint", al entrar de nuevo en la partida, bien esto me esta costando sudores porque ponga done ponga el jugador, en el nivel que sea simpre recuerda esas coordenadas.Y por mucho que intente pasar de nivel simpre me recuerda las coordenadas y aparece en ese sitio.Los que puse en la estatua es esto  
#pragma strict
private var theCollider : String;

function OnTriggerEnter (other : Collider)
{
theCollider = other.tag;
if (theCollider == "jugador")
{
PlayerPrefs.SetFloat("Checkpointx", gameObject.transform.position.x);
PlayerPrefs.SetFloat("Checkpointy", gameObject.transform.position.y);
PlayerPrefs.SetFloat("Checkpointz", gameObject.transform.position.z);
}
}
y esto en el jugador:
pragma strict
function Start () {
gameObject.transform.position.x = PlayerPrefs.GetFloat("Checkpointx");
gameObject.transform.position.y = PlayerPrefs.GetFloat("Checkpointy");
gameObject.transform.position.z = PlayerPrefs.GetFloat("Checkpointz");
}
y bien por mucho que desactivo estos scripts hasta borrar la estatua el Unity lo recuerda y claro cuando subo al nivel 1 me lleva al ultimo lugar donde estaba dicha estatua....como demonios le borro la memoria al Unity?.Me tiene pillado los player pref....si cargara el unity sin los scripts ?, se limpiaria?Ideas por favor...:( 
#50
General (Antiguo) / Necesito una idea...
Julio 22, 2015, 02:21:15 PM
Vereis necesito una idea de como proceder....
using UnityEngine;
using System.Collections;

public class PlayerInfo : MonoBehaviour {
public GameObject Bocaarma;
public GameObject healthBottle;
public GameObject player;
public AudioClip deathClip;
public AudioClip deathClip2;
public AudioSource sonido;
public AudioSource sonido2;
public GameObject sonidoisladino;
public GameObject sonidoaguadino2;
public GameObject sonidoaguadino1;
public GameObject sonidoaguadino3;
public GameObject sonidoaguadino4;
public GameObject sonidoaguadino5;
public GameObject sonidoaguadino6;
public GameObject sonidoaguadino7;
public Animation muerto2;

public float length;
//public AnimationClip Die;

int health = 100;
int damageCount = 0;
int currentHealth;
bool playerFighting;
public GUIText healthbar;
float timer = 0.0f;
float healthTimer = 0.0f;
bool healthShouldRespawn = false;

public bool muerto = false;
public GameObject tuUI;

void Start () {
   currentHealth = health;
   tuUI.SetActive(false);
   }

void Update () {
   Cursor.visible = false;
   print("player in combat? " + playerFighting);
   if(!playerFighting){
      print("player is not fighting");
      if(currentHealth != 100){
         timer += Time.deltaTime;
         print ("timer: " + timer);
         if(timer > 90.0f){
            currentHealth += 10;
            timer = 0.0f;
         }
      }
   }
   else
   {
      if(currentHealth <= 0 && !muerto ){
         muerto = true;
         sonido.PlayOneShot(deathClip2);
         muerto2.Play("muerto");
         //GetComponent<AudioSource>().enabled = false;
         //GetComponent<AudioSource>().PlayOneShot(deathClip2);//length =5f;
         GetComponent<FPSInputController>().enabled = false;
         GetComponent<CharacterController>().enabled = false;
         Bocaarma.SetActive(false);
         sonidoisladino.SetActive(false);
         sonidoaguadino2.SetActive(false);
         sonidoaguadino3.SetActive(false);
         sonidoaguadino4.SetActive(false);
         sonidoaguadino5.SetActive(false);
         sonidoaguadino6.SetActive(false);
         sonidoaguadino7.SetActive(false);
         sonidoaguadino1.SetActive(false);
         
      

         
         //Destroy(gameObject);


   
      }
   }
   healthbar.text = "Vida " + currentHealth + " / 100";
   
   if(healthShouldRespawn)
   {
      healthTimer += Time.deltaTime;
      
      if(healthTimer > 5.0f)
      {
         healthBottle.gameObject.SetActive(true);
         healthTimer = 0.0f;
      }
   }
   
   if(muerto){
      //var anim = GetComponent<Animation>();
      //anim.AddClip(Die,"attackbo");
      //anim.play("attackbo");
      //GetComponent<AudioSource>().PlayOneShot(deathClip2);length =5f;
      Cursor.visible = false;
      tuUI.SetActive(true);
      if(Input.GetKeyDown(KeyCode.Space)){
         Respawn();
      }
   }
   
}

public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      if(currentHealth < 0){
         currentHealth = 0;
      }
      currentHealth = currentHealth - 30;
      sonido2.PlayOneShot(deathClip);
      //GetComponent<AudioSource>().PlayOneShot(deathClip);
      //GetComponent<AudioSource>().PlayOneShot(deathClip);//length =3f;
      healthbar.text = "Health " + currentHealth + " / 100";
      damageCount = 0;
   }
   
   print(currentHealth);
}

public void playerInCombat(int combat){
   if(combat == 1){
      playerFighting = true;
   }
   else
   {
      playerFighting = false;
   }
}

public void Respawn(){
   tuUI.SetActive(false);
   muerto = false;
   transform.position = new Vector3(Random.Range(400.0f, 700.0f), 0, Random.Range(300.0f, 800.0f));
   GetComponent<FPSInputController>().enabled = true;
   GetComponent<CharacterController>().enabled = true;
   sonidoisladino.SetActive(true);
   sonidoaguadino2.SetActive(true);
   sonidoaguadino3.SetActive(true);
   sonidoaguadino4.SetActive(true);
   sonidoaguadino5.SetActive(true);
   sonidoaguadino6.SetActive(true);
   sonidoaguadino7.SetActive(true);
   sonidoaguadino1.SetActive(true);
   ///GetComponent<AudioSource>().enabled = true;
   //GetComponent<disparosyrecargos2>().enabled = true;
   ////GetComponent<MouseLook>().enabled = true;
   Bocaarma.SetActive(true);
   currentHealth = 100;
}

void OnTriggerEnter(Collider item){
   if(item.gameObject.tag == "PlayerHealthBottle")
   {
      if(currentHealth < 100)
      {
         currentHealth = currentHealth + 50;
         item.gameObject.SetActive(false);
         healthShouldRespawn = true;
      }
   }
}
}
Explicoeste script es bastante fundamental en mi desarrollo de el juego ya que esta vinculado a varias cosas....Bien , el scrip va de fabula ese no es el problema, la cosa es que en la linea 139 hasta la 142...public void Respawn(){ 
        tuUI.SetActive(false);
        muerto = false;
        transform.position = new Vector3(Random.Range(400.0f, 700.0f), 0, Random.Range(300.0f, 800.0f));es donde cuando mi personaje muere respawnea aleatoriamente en las coordenadas puestas. Ok , todo bien esto esta bien en el nivel 1El problema empieza en el nivel 2....que es una gruta....y claro si respawnea en estas aleatorias corrdenadas evidentemente se va al traste por el espacio.-... La solución que pense es copiarlo ponerle por ej:playerinfo2 y correjir las coordenadas mas cortas etc....pero al cambiarle el nombre tambien fallan otros muchos scrips vinculados a playerinfo incluidos vida, daño etc.... Alguna idea?Como dejar intacto el pastel y modificar eso? sin renombrar? Gracias de antemano.    
#51
General (Antiguo) / Animacioón recarga...
Julio 21, 2015, 08:29:38 AM
Buenoooo, despues de la ayuda hace unas semanas he avanzado terriblemente bien en mi proyecto , gracias a todos de nuevo por las ayudas/ideas me fueron geniales. Pero...llego el parche using UnityEngine;
using System.Collections;
public class disparosyrecargos2 : MonoBehaviour {
public Rigidbody Bala;
public float Velocidad = 80;
public float municion = 10;
public Animation reload;
float municionderecargo = 10;
public float municiontotal = 200;
///public static float municiontotal = 150;
public disparosyrecargos2 MyScriptShoot;
public float Conteo = 0;
public GUIText guimuni;
public GUIText guitotal;
public GameObject destello;
//public GameObject manoanim;
public GameObject expulsabalas;
//GameObject municionanim;
//AudioClip sonido;
public AudioClip recarga;
public AudioClip gunShot;
public AudioClip vacio;
void Start (){

destello.active = false;
}

void Update (){

guimuni.text = "Balas " + municion.ToString();
guitotal.text = "Total Balas " + municiontotal.ToString();

    //if (Input.GetButton("Fire1")){
if(Input.GetMouseButtonDown(0)){   
        Conteo = Conteo + 1;
       
    if(Conteo > 1){
    
     Conteo = 0;
}   
    if(Conteo == 1 && municion > 0 && municiontotal >= 0){
          
        //var clona=Instantiate(Bala, transform.position, transform.rotation);
   //clona.velocity = transform.TransformDirection(Vector3(0, 0, Velocidad));
   Rigidbody clone;
   clone=Instantiate(Bala, transform.position, transform.rotation) as Rigidbody;
   clone.velocity = transform.TransformDirection(Vector3.forward * 400);
   municion -= 1;
         Destroy (clone,1.0f);
   GetComponent<AudioSource>().PlayOneShot(gunShot);
   //AudioSource.PlayClipAtPoint(gunShot, transform.position, 1);//AudioListener.volume = 0.2f;
}
}
if(Input.GetKeyDown("r") && municiontotal > 0 && !Input.GetMouseButton(0) && !Input.GetMouseButton(1)){
reload.Play("reload");
municion = 0;
    Invoke ("recargando",2);
    AudioSource.PlayClipAtPoint(recarga, transform.position, 1);
 
}

if(Input.GetMouseButtonDown(0)){
///AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = true;
}
else
if(Input.GetMouseButtonUp(0)){
//AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = false;
}   
if (municion <= 0){
if(Input.GetMouseButtonUp(0)){
expulsabalas.SetActive(false);
AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = false;
}   
}
}
void recargando (){

expulsabalas.SetActive(true);
if(municiontotal > 0){
municiontotal -= municionderecargo;
municion += municionderecargo;

}
if (municion > municionderecargo){
municion = municionderecargo;
}
}
Linea 7:public Animation reload; animación publica que me pide en el inspector que tengo en un gameobject , se la pongo.linea 55:reload.Play("reload"); le digo que me reproduzca despues de apretar al "r" la animación que tengo metidilla dentro de el gameobject que me lo reconoce como animación y se llama reload. por si las moscas y para descartar he puesto un animator....con esa animación tambien pero....ni errores ni animación. Ideas por favor? Gracias de antemanooooo
#52
Hola muy buenas tengo un dilema que me trae de cabeza, aver si alguien tiene una idea diferente....
 
 
La cosa es que tengo una zona la principal, que cuando se activa un Ontriggerenter empieza a sonar una música y si sales se para...esto funciona bien.
 
 
Pero la cosa se estropea cuando mi personaje se tele trasporta a otra zona no un nuevo nivel, zona de el mismo plano, se activa otra musica y arranca bien hasta que mi personaje muere en la zona tele transportada y reaparece en la zona principal donde empieza a sonar el primer trigger pero el segundo no se para.....
 
 
Osea que suenan los dos a la vez.
 
Lo que quisiera es que, se parara cada uno al salir de su radio, pero parece que al morir como se va a un vector3 no se entera de que se ha ido de el trigger.....
 
Creo que me explico..
 
 
este es el script que uso que al reconocer al jugador, activa o desactiva el audio, repito funciona bien mientras este fisicamente en el sphere collither pero si muere....digamos que vuela al respawn XX no se detecta y no para.
 
 
el script:

#pragma strict
private var theCollider : String;
function OnTriggerEnter (other : Collider)
{
theCollider = other.tag;
if (theCollider == "jugador")
{
   GetComponent.<AudioSource>().Play();
   //GetComponent.<AudioSource>().loop = false;
}
}
function OnTriggerExit (other : Collider)
{
theCollider = other.tag;
if (theCollider == "jugador")
{
   GetComponent.<AudioSource>().Stop();
   //GetComponent.<AudioSource>().loop = false;
}
}

Gracias de antemano!!!!
 
 
 
#53
General (Antiguo) / Personaje aparece mal en escena
Julio 11, 2015, 01:59:21 AM
Hola Compis , me ha pasado una cosa muy rara , sin mas , aver si alguien le ha pasado.
 
Estaba yo con mis cosillas construyendo level y fui a probar la escena y resulta que mi player el de primera persona , por mucho que le digo que aparezca "aquí" osea moviendolo por el mapa y dejándolo hay , siempre parece en una esquina de el mapa pegadillo allí .....y no he cambiado nada de vectors ni de nada.
 
Alguna idea de porque le tiene tanto aprecio a ese rincón?
 
 
Llevo horas intentando averiguar que ha podido ser......lo raro es que tengo otra escena y el jodio tambien aparece en la dichosa esquina de el mapa......
 
 
Si se os ocurre algo lo que sea....
 
Gracias!!!!
 
Saludos
 
#54
General (Antiguo) / Un regalo para todos!!
Julio 09, 2015, 03:35:41 PM
Por razones de lo que no quieras para ti no lo desees a nadie  , he modificado el post y no estara disponible el script de conversion,
 
Para compensarlo , os dejo un barco pirata(creo), totalmente gratuito!!, el autor asi lo dispuso.
 
Lo podeis importar a Unity y usarlo si os apetece )
 
Saludos a ProgramaciónWH  y a Howling Wolf
 
 
 
 
 
 
sail_warshipFree.rarAmerWarship.zip
#55
General (Antiguo) / Clonar enemigo....
Julio 09, 2015, 03:22:09 PM
Holaaaaaaa ya estoy aqui de nuevo necesitando de vuestros sabios consejos....
 
Vereis me cree un enemigo que al detectarme, al jugador en este caso a una distancia x se me tira encima y me empieza a pegar mamporrios hasta que muero o lo mato.
 
Esto funciona de perlas, lo logreee
 
 
La cosa es que dentro de mi ignorancia dije si tengo 1...puedo hacer 100?, lo convierto en gameobject lo clono y listo?
 
 
Pues no....si lo duplico ni se mueve ni ataca ni nada!!!.
 
 
Ver el script y explico lo que tengo que hacer para que funcione.

using UnityEngine;
using System.Collections;
public class skellyattack : MonoBehaviour {
public GameObject player;
public GameObject skelly;
public float distance;
public PlayerInfo character;
   
   // Use this for initialization
   void Start () {
   }
   
   // Update is called once per frame
   void Update () {
      
   player = GameObject.FindWithTag("jugador");
   skelly = GameObject.FindWithTag("skelly1");
   distance = Vector3.Distance(player.transform.position,skelly.transform.position);
      
      if (distance <= 3) {
      skelly.GetComponent<Animation>().CrossFadeQueued("Run", 0.3f, QueueMode.PlayNow);
      skelly.GetComponent<Animation>().CrossFade("SwingHeavy");
      character.ApplyDamage(1);
      character.playerInCombat(1);
      }
      else if (distance < 50 && distance > 3.0f) {
      skelly.GetComponent<Animation>().CrossFadeQueued("SwingHeavy", 0.3f, QueueMode.PlayNow);
      skelly.GetComponent<Animation>().CrossFade("Run");
      skelly.transform.LookAt(player.transform.position);
         transform.position = Vector3.MoveTowards(transform.position, player.transform.position, 0.30f);
         //character.playerInCombat(1);
         
      }   
      else
      {
      skelly.GetComponent<Animation>().CrossFadeQueued("Run", 0.3f, QueueMode.PlayNow);
      skelly.GetComponent<Animation>().CrossFade("IdleHoldSword");
      character.playerInCombat(1);
      }
   }
   
   
}

bien , la unica manera de que me funciones es cambiando algunos nombres de el script tales como:
 
La public class a un mumero mas de el que tenia por ej:
 
public class skellyattack : MonoBehaviour {
 
a 
 
public class skellyattack1 : MonoBehaviour {
 
tambin el public GameObject skelly;
 
a 
 
public GameObject skelly1;
 
y asi sucesivamente y funcionan individualmemente pero es un toston hacerlos uno por uno....
 
 
Veis alguna forma de que se pueda clonar sin tener que hacerlos a mano cada 1?
 
 
el resto de el script funciona bien simpre y cuando le respete las variables que he comentado antes osea en cada script la 1, 2l 2 etc.
 
 
Gracias de antemano!!!!
 
 
 
 
 
#56
General (Antiguo) / non-static member???
Julio 08, 2015, 09:45:17 PM
Holaaaa muy buenas!!!
 
tengo una duda que me trae de cabeza.
 
Tengo este script en c#

using UnityEngine;
using System.Collections;
public class disparosyrecargos2 : MonoBehaviour {
public Rigidbody Bala;
float Velocidad = 80;
public float municion = 20;
float municionderecargo = 20;
public float municiontotal = 150;
float Conteo = 0;
public GUIText guimuni;
public GUIText guitotal;
public GameObject destello;
public GameObject manoanim;
//GameObject municionanim;
//AudioClip sonido;
public AudioClip recarga;
public AudioClip gunShot;
public AudioClip vacio;
void Start (){
destello.active = false;
}
void Update (){
guimuni.text = "Balas " + municion.ToString();
guitotal.text = "Total Balas " + municiontotal.ToString();
    if (Input.GetButton("Fire1")){
       
        Conteo = Conteo + 1;
       
    if(Conteo > 20){
    
     Conteo = 0;
}   
    if(Conteo == 20 && municion > 0 && municiontotal >= 0){
          
        //var clona=Instantiate(Bala, transform.position, transform.rotation);
   //clona.velocity = transform.TransformDirection(Vector3(0, 0, Velocidad));
   Rigidbody clone;
   clone=Instantiate(Bala, transform.position, transform.rotation) as Rigidbody;
   clone.velocity = transform.TransformDirection(Vector3.forward * 90);
   municion -= 1;
         Destroy (clone,1.0f);      
   AudioSource.PlayClipAtPoint(gunShot, transform.position, 1);AudioListener.volume = 0.1f;
}
}
if(Input.GetKeyDown("r") && municiontotal > 0 && !Input.GetMouseButton(0) && !Input.GetMouseButton(1)){
    
///GetComponent.<Animation>().Play("Reload");
    municion = 0;
    Invoke ("recargando",2);
    AudioSource.PlayClipAtPoint(recarga, transform.position, 1);
 
}
if(Input.GetMouseButtonDown(0)){
///AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = true;
}
else
if(Input.GetMouseButtonUp(0)){
//AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = false;
}   
if (municion <= 0){
if(Input.GetMouseButtonUp(0)){
AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
destello.active = false;
}   
}
}
void recargando (){
if(municiontotal > 0){
municiontotal -= municionderecargo;
municion += municionderecargo;
}
if (municion > municionderecargo){
municion = municionderecargo;
}
}

el script en si funciona bien el problema es cuando le agrego a un cubo objeto"cualquiera" este script diminuto para que me añada balas a la municiontotal cuando entre en su triger....bien pues me tira este error.
 
Primero el script tanbien en c#

using UnityEngine;
using System.Collections;
public class recargamunicion2 : MonoBehaviour {
// Use this for initialization
   void OnTriggerEnter (Collider other) {
      if(other.gameObject.name == "Jugador"){
         // Accedo al script de ArmasEstado y actualizo la MunicionActual.
         disparosyrecargos2.municiontotal=100; ////aqui llamo al otro script y intento añadirle..
         // Destruyo el cargador de municion
         Destroy(other.gameObject);
   }
}
}

y el error:
 
recargamunicion2.cs(11,52): error CS0120: An object reference is required to access non-static member `disparosyrecargos2.municiontotal'
 
 
alguna idea porfavor?
 
Gracias!!!!!!!!!!!
 
 
 
 
 
#57
Muy buenas a todos , después de varios meses de un proyecto a base de tortas  , me he encontrado que no puedo seguir por cualpa de un script que esta en C# y deberia estar en Java.
 
Si alguien fuese tan amable de convertírmelo en java le estaría eternamente agradecido y seguiria mi proyecto.
 
Dejo el script aqui por si alguien se quiere tomar la molestia...gracias de antemano.

#58
Hola gente guay, me estoy rompiendo los cuernos y no hay manera de poder poner un cuadradito con unas simples letras que pongan Reaparecer y que cuando clicke este cuadro respawnee mi personaje.
 
 
El script que tengo esta asi:

using UnityEngine;
using System.Collections;
public class PlayerInfo : MonoBehaviour {
public GameObject healthBottle;
public GameObject player;
public AudioClip deathClip;
public AudioClip deathClip2;
public float length;
int health = 100;
int damageCount = 0;
int currentHealth;
bool playerFighting;
public GUIText healthbar;
float timer = 0.0f;
float healthTimer = 0.0f;
bool healthShouldRespawn = false;
bool muerto= false;
// Use this for initialization
void Start () {
   currentHealth = health;
}

// Update is called once per frame
void Update () {
   Cursor.visible = false;
   print("player in combat? " + playerFighting);
   if(!playerFighting){
      print("player is not fighting");
      if(currentHealth != 100){
         timer += Time.deltaTime;
         print ("timer: " + timer);
         if(timer > 90.0f){
            currentHealth += 10;
            timer = 0.0f;
         }
      }
   }
   else
   {
      if(currentHealth <= 0 && !muerto ){
         muerto=true;
         GetComponent<AudioSource>().PlayOneShot(deathClip);length = 5f;
         Invoke("Respawn",5);
      }
   }
   healthbar.text = "Vida " + currentHealth + " / 100";
   
   if(healthShouldRespawn)
   {
      healthTimer += Time.deltaTime;
      
      if(healthTimer > 5.0f)
      {
         healthBottle.gameObject.SetActive(true);
         healthTimer = 0.0f;
      }
   }
   
}

public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      currentHealth = currentHealth - 30;
      GetComponent<AudioSource>().PlayOneShot(deathClip2);length = 0.2f;
      healthbar.text = "Health " + currentHealth + " / 100";
      damageCount = 0;
   }
   
   print(currentHealth);
}

public void playerInCombat(int combat){
   if(combat == 1){
      playerFighting = true;
   }
   else
   {
      playerFighting = false;
   }
}
void Respawn(){
   muerto=false;
   transform.position = new Vector3(Random.Range(50.0f, 120.0f), 0, Random.Range(10.0f, 200.0f));
   currentHealth = 100;
}
void OnTriggerEnter(Collider item){
   if(item.gameObject.tag == "PlayerHealthBottle")
   {
      if(currentHealth < 100)
      {
         currentHealth = currentHealth + 50;
         item.gameObject.SetActive(false);
         healthShouldRespawn = true;
      }
   }
}



linea 44 el personaje muere y llama a la funcion respawn despues de 5 segundos , esto se quitara si consigo el boton.
 
linea 83 empieza la funcion respawn y respaunea el personaje en las corrdenadas ramdom que estan asignadas.
 
Bien hasta aqui todo furula, pues bien me encantaria que alguien me dijera como poner antes de que el personaje respawnee un boton en pantalla que diga eso Reaparecer o algo asi y que cuando lo clickeee o apriete una letra o lo que sea siga con el random respawn tal y como hace ahora.
 
He mirado varios tutoriales pero sin exito, algunos porque estan en JS, otros porque no son precisamente esto....
 
Pido ayuda por favor.
 
Gracias de antemano, ya se que es una tontria pero no me sale...
 
 
#59
Hola, mis queridos amigos necesito un consejo de nuevo
 
Quiero que antes de que mi PJ muera y respawnee en una posición aleatoria(eso funciona bien) , que tenga una pequeña pausa(posterior animación que ya vendra), le he insertado una pausa antes de que eso pase pero me tira un error muy raro que no se porque....
 
 
Adjunto script completo:

using UnityEngine;
using System.Collections;
    public class PlayerInfo : MonoBehaviour {
public GameObject healthBottle;
public GameObject player;
public AudioClip deathClip;
public AudioClip deathClip2;
public float length;
int health = 100;
int damageCount = 0;
int currentHealth;
bool playerFighting;
public GUIText healthbar;
float timer = 0.0f;
float healthTimer = 0.0f;
bool healthShouldRespawn = false;
// Use this for initialization
void Start () {
currentHealth = health;
}

// Update is called once per frame
void Update () {
   Cursor.visible = false;
   print("player in combat? " + playerFighting);
   if(!playerFighting){
      print("player is not fighting");
      if(currentHealth != 100){
         timer += Time.deltaTime;
         print ("timer: " + timer);
         if(timer > 90.0f){
            currentHealth += 10;
            timer = 0.0f;
         }
      }
   }
   else
   {
      if(currentHealth <= 0){
         GetComponent<AudioSource>().PlayOneShot(deathClip);length = 0.5f;
         yield return new WaitForSeconds (5);// esta linea es la de pausa y la que da problemas
         transform.position = new Vector3(Random.Range(50.0f, 120.0f), 0, Random.Range(10.0f, 200.0f));
         currentHealth = 100;
      }
   }
   healthbar.text = "Vida " + currentHealth + " / 100";
   if(healthShouldRespawn)
   {
      healthTimer += Time.deltaTime;
      if(healthTimer > 5.0f)
      {
         healthBottle.gameObject.SetActive(true);
         healthTimer = 0.0f;
      }
   }
}
public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      currentHealth = currentHealth - 30;
      GetComponent<AudioSource>().PlayOneShot(deathClip2);length = 0.2f;
      healthbar.text = "Health " + currentHealth + " / 100";
      damageCount = 0;
   }
   print(currentHealth);
}
public void playerInCombat(int combat){
   if(combat == 1){
      playerFighting = true;
   }
   else
   {
      playerFighting = false;
   }
}
void OnTriggerEnter(Collider item){
   if(item.gameObject.tag == "PlayerHealthBottle")
   {
      if(currentHealth < 100)
      {
         currentHealth = currentHealth + 50;
         item.gameObject.SetActive(false);
         healthShouldRespawn = true;
      }
   }
}
 
}

la linea 42...alli tengo la pausa....y me tira este error:
 
error CS1624: The body of `PlayerInfo.Update()' cannot be an iterator block because `void' is not an iterator interface type
 
 
Grrr alguna solucion a la vista?
 
Gracias de antemanoooo
 
 
 
 
 
 
#60
Hola , alguna idea de como detener un script que es de JS , detenerlo desde el codigo c#? de c# a c# no he tenido problemas pero al reves si...
 
Ejemplo del No funciona.
 
El nombre de el script de java que se esta ejecutando y quiero detener en un momento de deteccion de un enemigo es FollowPath
 
Aqui lo intento detener desde c#

else if (distance < 50 && distance > 3.0f) {
      GetComponent<FollowPath>().enabled = false; /// aqui lo intento parar...
      skelly1.GetComponent<Animation>().CrossFadeQueued("SwingHeavy", 0.3f, QueueMode.PlayNow);
      skelly1.GetComponent<Animation>().CrossFade("Run");
      skelly1.transform.LookAt(player.transform.position);
      transform.position = Vector3.MoveTowards(transform.position, player.transform.position, 0.30f);
      character.playerInCombat(1);

Agradecería una idea.