Ya me funciono, le puse un rigybody y funciono.. alguien me dise porque funciono..???que no tengo idea.....!!!
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.
#47
General (Antiguo) / Ayuda con un codigo
Febrero 01, 2016, 01:03:29 AM
No entiendo que pasa ya verifique el enemigo tiene el tag ya intente que colisione con el personaje y si funciona y le puse el tag al personaje pero tampoco funciona es como si el tag no tubiera valor para el codigo como si no existiera
#48
General (Antiguo) / Ayuda con un codigo
Enero 31, 2016, 01:30:42 AM
aun no le reconoce le disparo y no sucede nada
#49
General (Antiguo) / Ayuda con un codigo
Enero 30, 2016, 10:22:21 PM
Ayuda tengo estos dos codigos uno es el AI de un enemigo y el otro es el codigo de la bala de mi jugador no se que pasa que cuando la bala entra en el collider del enemigo no le baja vida me podrian ver que pasa....Este es el de la balapublic bool right;
public bool prueba = false; public float velocidad = 10;
public float TimeDestroy = 10; public int dmg = 25; private FirePlantAI fire; void Start()
{
fire = GameObject.FindGameObjectWithTag("Enemy").GetComponent<FirePlantAI>();
} void Update()
{
Destroy(gameObject, TimeDestroy);
if (prueba)
{
fire.prueba = true;
} if (right)
{
transform.Translate(Vector3.right * Time.deltaTime * velocidad, Camera.main.transform);
}
else
{
transform.Translate(Vector3.left * Time.deltaTime * velocidad, Camera.main.transform);
} }
void OnTriggerEnter2D(Collider2D col)
{
if (col.isTrigger != true && col.CompareTag("Enemy"))
{
col.SendMessageUpwards("Damage", dmg);
// Destroy(gameObject);
}
}
} y este el del AI
public int curHealth;
public int maxHealth = 100; public float distance;
public float wakeRange;
public float shootInterval;
public float bullerSpeed = 100;
public float bulletTimer; public bool Rise = false;
public bool Right = true;
public bool prueba = false; public GameObject bullet;
public Transform target;
public Animator anim;
public Transform shootPointLeft;
public Transform shootPointRight; void Awake()
{
anim = gameObject.GetComponent<Animator>(); }
void Start()
{
curHealth = maxHealth;
}
void Update()
{
if (curHealth <= 0)
{
Die();
}
if (curHealth > maxHealth)
{
curHealth = maxHealth;
}
anim.SetBool("Rise", Rise);
anim.SetBool("Right", Right); RangeCheck();
if (target.transform.position.x > transform.position.x)
{
Right = true;
}
if (target.transform.position.x < transform.position.x)
{
Right = false;
}
}
void RangeCheck()
{
distance = Vector3.Distance(transform.position, target.transform.position);
if (distance < wakeRange)
{
Rise = true;
}
if(distance > wakeRange)
{
Rise = false;
}
} public void Attack(bool attackingRight)
{
bulletTimer += Time.deltaTime; if (bulletTimer >= shootInterval)
{
Vector2 direction = target.transform.position - transform.position;
direction.Normalize(); if (!attackingRight)
{
GameObject bulletClone;
bulletClone = Instantiate(bullet, shootPointLeft.transform.position, shootPointLeft.transform.rotation) as GameObject;
bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bullerSpeed; bulletTimer = 0;
}
if (attackingRight)
{
GameObject bulletClone;
bulletClone = Instantiate(bullet, shootPointRight.transform.position, shootPointRight.transform.rotation) as GameObject;
bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bullerSpeed; bulletTimer = 0;
}
}
}
public void Damage(int damage)
{
curHealth -= damage;
gameObject.GetComponent<Animation>().Play("Player_Damage"); }
void Die()
{
Destroy(gameObject);
} Grasias por su atencion..
public bool prueba = false; public float velocidad = 10;
public float TimeDestroy = 10; public int dmg = 25; private FirePlantAI fire; void Start()
{
fire = GameObject.FindGameObjectWithTag("Enemy").GetComponent<FirePlantAI>();
} void Update()
{
Destroy(gameObject, TimeDestroy);
if (prueba)
{
fire.prueba = true;
} if (right)
{
transform.Translate(Vector3.right * Time.deltaTime * velocidad, Camera.main.transform);
}
else
{
transform.Translate(Vector3.left * Time.deltaTime * velocidad, Camera.main.transform);
} }
void OnTriggerEnter2D(Collider2D col)
{
if (col.isTrigger != true && col.CompareTag("Enemy"))
{
col.SendMessageUpwards("Damage", dmg);
// Destroy(gameObject);
}
}
} y este el del AI
public int curHealth;
public int maxHealth = 100; public float distance;
public float wakeRange;
public float shootInterval;
public float bullerSpeed = 100;
public float bulletTimer; public bool Rise = false;
public bool Right = true;
public bool prueba = false; public GameObject bullet;
public Transform target;
public Animator anim;
public Transform shootPointLeft;
public Transform shootPointRight; void Awake()
{
anim = gameObject.GetComponent<Animator>(); }
void Start()
{
curHealth = maxHealth;
}
void Update()
{
if (curHealth <= 0)
{
Die();
}
if (curHealth > maxHealth)
{
curHealth = maxHealth;
}
anim.SetBool("Rise", Rise);
anim.SetBool("Right", Right); RangeCheck();
if (target.transform.position.x > transform.position.x)
{
Right = true;
}
if (target.transform.position.x < transform.position.x)
{
Right = false;
}
}
void RangeCheck()
{
distance = Vector3.Distance(transform.position, target.transform.position);
if (distance < wakeRange)
{
Rise = true;
}
if(distance > wakeRange)
{
Rise = false;
}
} public void Attack(bool attackingRight)
{
bulletTimer += Time.deltaTime; if (bulletTimer >= shootInterval)
{
Vector2 direction = target.transform.position - transform.position;
direction.Normalize(); if (!attackingRight)
{
GameObject bulletClone;
bulletClone = Instantiate(bullet, shootPointLeft.transform.position, shootPointLeft.transform.rotation) as GameObject;
bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bullerSpeed; bulletTimer = 0;
}
if (attackingRight)
{
GameObject bulletClone;
bulletClone = Instantiate(bullet, shootPointRight.transform.position, shootPointRight.transform.rotation) as GameObject;
bulletClone.GetComponent<Rigidbody2D>().velocity = direction * bullerSpeed; bulletTimer = 0;
}
}
}
public void Damage(int damage)
{
curHealth -= damage;
gameObject.GetComponent<Animation>().Play("Player_Damage"); }
void Die()
{
Destroy(gameObject);
} Grasias por su atencion..
#50
General (Antiguo) / Botones y Input UI
Enero 19, 2016, 04:00:11 AM
El OnMouseEnter ya lo usepublic void OnMouseEnter (){texto.SetActive(true);}pero cuando paso el mouse por encima del boton no ocure nada..... que me falta hacer.?ya le intente poner un collider
#51
General (Antiguo) / Botones y Input UI
Enero 16, 2016, 01:51:28 AM
Losiento por repetir post esque mi com***dora no me deja postear en la pagina y no se porque pasa eso y el otro post ya se fue mu abajo.... Al tema quiero hacer 2 cosas. 1. Cuando pase el puntero del mouse por encima del boton sin hacer click aparesca o un texto o una imagen, cualquiera de las dos me sirve.2. Cuando escriba en el input el texto que escriba salga en un objeto text UI. Si alguien me puede ayudar con esas cosas me ayudarian muchisimo...!!!Grasias por su atencion..
#52
General (Antiguo) / Problemas con botones UI
Enero 09, 2016, 08:59:12 PM
Muy buenas a todos tengo un problema, quiero hacer botones que cuando se pase el mouse encima sin hacer click aparesca una informacion...porque cuando hace click aparece un menu donde se escribe el nombre, de ahi quiero hacer que cuando escriba el nombre en el Input field aparesca en un objeto text... si me ayudan con esas 2 cositas me arian el hombre mas feliz del mundo....!!!! grasias por su atencion
#53
General (Antiguo) / Guardar y cargar datos
Enero 04, 2016, 11:12:05 PM
Disculpen la demora a responder mi com***dora tiene algun virus que no me deja escribir o responder es algo extraño bueno al caso... Mi juego es de Pc no Android y no se como usar XML use este sistema que esta arriba porque lo explican en los recursos de Unity... me podrian ayudar con el codigo o explicarme como usar XML para mi caso porque intento guardar 2 datos la experiencia y cuantos nivel a cruzado....
#54
General (Antiguo) / Guardar y cargar datos
Enero 02, 2016, 07:43:04 PM
Hola a todos tengo una duda un poco complicada y que no llego a entender disene este codigo para guardar y cargar datos de experiencia y funciona muy bien y ahora le instale para que me guarde en que nivel esta el jugador pero cuando inicio la partida ningun deja de funcionar el codigo entero, aqui les dejo todo el script... using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using UnityEngine.UI;public class GameControl : MonoBehaviour { public static GameControl control; public float experienceunos;
public Text InputTextuno;
public Text pointsTextuno; public float experiencedoss;
public Text InputTextdos;
public Text pointsTextdos; public float experiencetress;
public Text InputTexttres;
public Text pointsTexttres; public bool uno = false;
public bool dos = false;
public bool tres = false; private Player player;
private DoorNivel dn; void Update(){
if (uno) {
InputTextuno.enabled = true;
pointsTextuno.enabled = true;
pointsTextuno.text = ("Points : " + experienceunos);
} else {
InputTextuno.enabled = false;
pointsTextuno.enabled = false;
}
if (dos) {
InputTextdos.enabled = true;
pointsTextdos.enabled = true;
pointsTextdos.text = ("Points : " + experiencedoss);
} else {
InputTextdos.enabled = false;
pointsTextdos.enabled = false;
}
if (tres) {
InputTexttres.enabled = true;
pointsTexttres.enabled = true;
pointsTexttres.text = ("Points : " + experiencetress);
} else {
InputTexttres.enabled = false;
pointsTexttres.enabled = false;
}
} void Start (){
player = gameObject.GetComponent<Player> ();
dn = gameObject.GetComponent<DoorNivel> ();
}
void Awake(){
if (control == null) {
control = this;
DontDestroyOnLoad (gameObject);
} else if (control != this) {
Destroy(gameObject);
}
}
// Update is called once per frame
void OnGUI () {
// GUI.Button (new Rect (10, 40, 100, 60), "Experience: " + experience); }
public void Save(){
if (uno) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat.uno");
PlayerData data = new PlayerData ();
// PlayerData data1 = new PlayerData ();
data.experienceuno = experienceunos;
// data1.levelReacheduno = dn.levelReacheduno;
bf.Serialize (file, data);
file.Close ();
}
if (dos) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat.dos");
PlayerData data = new PlayerData ();
// PlayerData data1 = new PlayerData ();
data.experiencedos = experiencedoss;
// data1.levelReacheddos = dn.levelReacheddos;
bf.Serialize (file, data);
file.Close ();
} }
public void Load(){
if (uno) {
if (File.Exists (Application.persistentDataPath + "/playerInfo.dat.uno")) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat.uno", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize (file);
// PlayerData data1 = (PlayerData)bf.Deserialize (file);
file.Close (); experienceunos = data.experienceuno;
// dn.levelReacheduno = data1.levelReacheduno;
} }
if (dos) {
if (File.Exists (Application.persistentDataPath + "/playerInfo.dat.uno")) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat.dos", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize (file);
// PlayerData data1 = (PlayerData)bf.Deserialize (file);
file.Close ();
experiencedoss = data.experiencedos;
// dn.levelReacheddos = data1.levelReacheddos;
}
} }}
[Serializable]
class PlayerData{
public float experienceuno;
public float experiencedos;
public float experiencetres;
public int levelReacheduno;
public int levelReacheddos;
public int levelReachedtres;
} anote en rojo el codigo que adjunte para guardar los datos de cuantos niveles paso el jugador.
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using UnityEngine.UI;public class GameControl : MonoBehaviour { public static GameControl control; public float experienceunos;
public Text InputTextuno;
public Text pointsTextuno; public float experiencedoss;
public Text InputTextdos;
public Text pointsTextdos; public float experiencetress;
public Text InputTexttres;
public Text pointsTexttres; public bool uno = false;
public bool dos = false;
public bool tres = false; private Player player;
private DoorNivel dn; void Update(){
if (uno) {
InputTextuno.enabled = true;
pointsTextuno.enabled = true;
pointsTextuno.text = ("Points : " + experienceunos);
} else {
InputTextuno.enabled = false;
pointsTextuno.enabled = false;
}
if (dos) {
InputTextdos.enabled = true;
pointsTextdos.enabled = true;
pointsTextdos.text = ("Points : " + experiencedoss);
} else {
InputTextdos.enabled = false;
pointsTextdos.enabled = false;
}
if (tres) {
InputTexttres.enabled = true;
pointsTexttres.enabled = true;
pointsTexttres.text = ("Points : " + experiencetress);
} else {
InputTexttres.enabled = false;
pointsTexttres.enabled = false;
}
} void Start (){
player = gameObject.GetComponent<Player> ();
dn = gameObject.GetComponent<DoorNivel> ();
}
void Awake(){
if (control == null) {
control = this;
DontDestroyOnLoad (gameObject);
} else if (control != this) {
Destroy(gameObject);
}
}
// Update is called once per frame
void OnGUI () {
// GUI.Button (new Rect (10, 40, 100, 60), "Experience: " + experience); }
public void Save(){
if (uno) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat.uno");
PlayerData data = new PlayerData ();
// PlayerData data1 = new PlayerData ();
data.experienceuno = experienceunos;
// data1.levelReacheduno = dn.levelReacheduno;
bf.Serialize (file, data);
file.Close ();
}
if (dos) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat.dos");
PlayerData data = new PlayerData ();
// PlayerData data1 = new PlayerData ();
data.experiencedos = experiencedoss;
// data1.levelReacheddos = dn.levelReacheddos;
bf.Serialize (file, data);
file.Close ();
} }
public void Load(){
if (uno) {
if (File.Exists (Application.persistentDataPath + "/playerInfo.dat.uno")) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat.uno", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize (file);
// PlayerData data1 = (PlayerData)bf.Deserialize (file);
file.Close (); experienceunos = data.experienceuno;
// dn.levelReacheduno = data1.levelReacheduno;
} }
if (dos) {
if (File.Exists (Application.persistentDataPath + "/playerInfo.dat.uno")) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat.dos", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize (file);
// PlayerData data1 = (PlayerData)bf.Deserialize (file);
file.Close ();
experiencedoss = data.experiencedos;
// dn.levelReacheddos = data1.levelReacheddos;
}
} }}
[Serializable]
class PlayerData{
public float experienceuno;
public float experiencedos;
public float experiencetres;
public int levelReacheduno;
public int levelReacheddos;
public int levelReachedtres;
} anote en rojo el codigo que adjunte para guardar los datos de cuantos niveles paso el jugador.
#55
General (Antiguo) / rotar true y false con la misma accion
Diciembre 04, 2015, 02:01:37 AM
ya lo aregle aqui les dejo como ise... if (col.isTrigger != true) {
if (col.CompareTag ("Enemy")) {
if (intercambiador) {
this.transform.Rotate (Vector3.up, 180);
right = false;
intercambiador = false;
}
else{
this.transform.Rotate (Vector3.up, 180);
right = true;
intercambiador = true;
} }ise una variable aparte para que sea repetible no e sido tan bruto jeje grasias con todo
if (col.CompareTag ("Enemy")) {
if (intercambiador) {
this.transform.Rotate (Vector3.up, 180);
right = false;
intercambiador = false;
}
else{
this.transform.Rotate (Vector3.up, 180);
right = true;
intercambiador = true;
} }ise una variable aparte para que sea repetible no e sido tan bruto jeje grasias con todo
#56
General (Antiguo) / rotar true y false con la misma accion
Diciembre 04, 2015, 12:36:18 AM
sabes cuales es el problema que acabo de analizar esque nesecito que cambie right a false cuando choque con otro enemy, no que cambie en 2 segundos, entonces seria que cada vez que choque a enemy cambie de right a false es para mi enemigo que cuando choque con otro no queden como retrasados.... losiento por mi falta
#57
General (Antiguo) / rotar true y false con la misma accion
Diciembre 03, 2015, 01:19:53 AM
lo que pasa ahora es que cuando choca con enemy se da la vuelta pero en 2 segundos vuelve a right = true, como hago que en vez de un tiempo gire, que cuando vuelva a entrar en un collider cambie a false, osea cada vez que choque con un collider enemy cambie su regla de true a false y viceversa. Pero me guardo que en un tiempo cambie me puede servir grasias , porfavor no mas ese detallito que me ayuden yo feliz, tambien ya cambien la los 2 if por un if y un else..
#58
General (Antiguo) / rotar true y false con la misma accion
Diciembre 02, 2015, 01:41:51 AM
Buenas a todos tengo una duda quiero que cuando el enemigo choque con otro se den la vuelta y sigan su curso ya logre q giren y avancen pero solo lo hacen una vez y no se como hacer un bucle o algo asi aqui les dejo el script que tengo... void Update () {
if (!right) {
transform.Translate (Vector3.left * Time.deltaTime * velocidad, Camera.main.transform);
}
if (right) {
transform.Translate (Vector3.right * Time.deltaTime * velocidad, Camera.main.transform);
}
} void OnTriggerEnter2D(Collider2D col){
if(col.isTrigger != true){
if(col.CompareTag("Player")){
col.GetComponent<Player>().Damage(1);
}
}
if (col.isTrigger != true) {
if(col.CompareTag("Enemy")){
this.transform.Rotate (Vector3.up, 180);
right = true;
}
}
}marque en rojo lo que quiero hacer q cada vez que compare Enemy eso aga true false true false asi no se si me entendieron.....
if (!right) {
transform.Translate (Vector3.left * Time.deltaTime * velocidad, Camera.main.transform);
}
if (right) {
transform.Translate (Vector3.right * Time.deltaTime * velocidad, Camera.main.transform);
}
} void OnTriggerEnter2D(Collider2D col){
if(col.isTrigger != true){
if(col.CompareTag("Player")){
col.GetComponent<Player>().Damage(1);
}
}
if (col.isTrigger != true) {
if(col.CompareTag("Enemy")){
this.transform.Rotate (Vector3.up, 180);
right = true;
}
}
}marque en rojo lo que quiero hacer q cada vez que compare Enemy eso aga true false true false asi no se si me entendieron.....
#59
General (Antiguo) / Crear juegos profesionalmente
Noviembre 30, 2015, 05:49:32 AM
Grasias a todos por responder el pos me a paresido muy curioso justo hoy estaba investigando y en francia a la ciudad donde voy (casualidad) hay una universidad que ensena a crear videojuegos, te ensena todo lo referido la parte grafica, informatica y empresarial para quien le interese es "Monpellier 3" aqui esta la pag le pueden traducir con el traductor (ni modo que con el zapato) "http://www.univ-montp3.fr/ufr1/index.php/formations/licences-professionnelles/jeux-video" Grasias por la ayuda y aqui les ayudo aqui le interesa
#60
General (Antiguo) / Crear juegos profesionalmente
Noviembre 29, 2015, 03:36:37 AM
Que necesito o que estudio para trabajar creando juegos de forma profesional como para llegar a trabajar con Infinity Ward, e tenido esta duda por este mes y no encuentro una información consistente, voy a viajar a francia despues de terminar el bachillerato y no se que estudiar en francia para ser un Game Designer si alguien me puede ayudar seria muy feliz..