http://hobblygobbly.tumblr.com/post/93960257057/how-to-setup-the-a-pathfinding-project-in-a-2d#disqus_thread FUNCIONA AL 100% GENTE RECOMENDADO PARA LOS QUIEREN TRABAJAR EN 2D
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.
#122
General (Antiguo) / Path finding unity2d
Octubre 10, 2015, 07:23:56 AM #123
General (Antiguo) / Path finding unity2d
Octubre 10, 2015, 06:22:26 AM
Hola me encontré este código según entiendo es scritp es una código para la version 4.5.0 de unity. cuando lo compilo en versiones superiores este me genera conflicto quisiera saber como solucionar el problema que al parecer que no me detecta ciertas variables. gracias ademas todo el agradecimiento a http://hobblygobbly.tumblr.com/
using UnityEngine;
using System.Collections;
//Note this line, if it is left out, the script won't know that the class 'Path' exists and it will throw compiler errors
//This line should always be present at the top of scripts which use pathfinding
using Pathfinding;
public class AstarAI : MonoBehaviour
{
//The point to move to
public Transform target;
private Seeker seeker;
//The calculated path
public Path path;
//The AI's speed per second
public float speed = 2;
//The max distance from the AI to a waypoint for it to continue to the next waypoint
public float nextWaypointDistance = 3;
//The waypoint we are currently moving towards
private int currentWaypoint = 0;
public void Start ()
{
seeker = GetComponent<Seeker>();
//Start a new path to the targetPosition, return the result to the OnPathComplete function
seeker.StartPath( transform.position, target.position, OnPathComplete );
}
public void OnPathComplete ( Path p )
{
Debug.Log( "Yay, we got a path back. Did it have an error? " + p.error );
if (!p.error)
{
path = p;
//Reset the waypoint counter
currentWaypoint = 0;
}
}
public void FixedUpdate ()
{
if (path == null)
{
//We have no path to move after yet
return;
}
if (currentWaypoint >= path.vectorPath.Count)
{
Debug.Log( "End Of Path Reached" );
return;
}
//Direction to the next waypoint
Vector3 dir = ( path.vectorPath[ currentWaypoint ] - transform.position ).normalized;
dir *= speed * Time.fixedDeltaTime;
this.gameObject.transform.Translate( dir );
//Check if we are close enough to the next waypoint
//If we are, proceed to follow the next waypoint
if (Vector3.Distance( transform.position, path.vectorPath[ currentWaypoint ] ) < nextWaypointDistance)
{
currentWaypoint++;
return;
}
}
}
#124
General (Antiguo) / Path finding unity2d
Octubre 10, 2015, 03:30:03 AM
BUENO VOY PUBLICANDO LOS RESULTADOS DE LO QUE VALLA ENCONTRANDO.ESTE ASSET ES MUY INTERESANTA Y ES GRATIS.https://www.assetstore.unity3d.com/en/#!/content/20087">https://www.assetstore.unity3d.com/en/#!/content/20087SI ALGUIEN TIENE ALGUNA OTRA INFORMACIÓN SE LOS AGRADECERÍA.
#125
General (Antiguo) / IA de un enemigo que se detenga antes de llegar a el
Octubre 10, 2015, 02:50:53 AM
SEÑOR NAVMESH TIENE UN INDICADOR DE RANGO DE DISTANCIA PARA CUANDO LLEGA AL OBJETIVO, DEBERÍAS MIRARLO, HAY QUE ESCRIBIRLE UNAS POCAS LINEAS DE CÓDIGO.
#126
General (Antiguo) / Path finding unity2d
Octubre 10, 2015, 01:16:25 AM
hola presento un inconveniente para un juego que estoy haciendo en 2d necesito que un objeto siga a otro y que esquive obstáculos para que llegue donde el esta el objetivo sin utilizar waypoints pero al parecer navimesh solo trabaja con unity3d por lo que no se si hay alguna manera de hacerlo en 2d.mi pregunta es hay alguna manera de que el objeto llegue al objetivo esquivando los obstáculo?, por hay investigue tutoriales de Pathfinding para unity2d pero al parecer están desactualizados con la version 5 alguno conocera algun tuto para unity5 o algún script para estudiarlo. Gracias por su tiempo.
#128
General (Antiguo) / problema unity Beat 'em up ??
Octubre 02, 2015, 11:58:33 PM #129
General (Antiguo) / problema unity Beat 'em up ??
Octubre 02, 2015, 11:19:41 PM
Hola llevo un tiempo queriendo hacer un Beat 'em up en 2D en unity, no he logrado crear un prototipo estable. no se si alguien podría darme alguna información de por donde puedo comenzar o alguna recomendación.gracias por tu atención.
#130
General (Antiguo) / este tuto es genial se los recomiendo me demore un tiempo para conseguir material que me ayudara para mi juego
Septiembre 07, 2015, 02:28:09 AM
eature=oembed" frameborder="0" allowfullscreen="true">
#131
General (Antiguo) / Problema al desactivar OnGUI.
Agosto 03, 2015, 04:37:54 AM
publico la solucion que me encontre si alguno le llega a pasar lo mismo o si quierevoid OnGUI()
{
if(desactivadorGui == true && activadorQuitavida == false)
{
BARRAVIDA = false;
desactivadorGui = false;
} else if(BARRAVIDA == true )
{ Debug.Log ("llegue a gui");
GUI.BeginGroup (new Rect (10, 10, 256, 16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFondo, barraVida);
GUI.BeginGroup (new Rect (0, 0, EnergiaEnemigo,16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFrente, barraVida);
GUI.EndGroup ();
GUI.EndGroup ();
}
}
{
if(desactivadorGui == true && activadorQuitavida == false)
{
BARRAVIDA = false;
desactivadorGui = false;
} else if(BARRAVIDA == true )
{ Debug.Log ("llegue a gui");
GUI.BeginGroup (new Rect (10, 10, 256, 16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFondo, barraVida);
GUI.BeginGroup (new Rect (0, 0, EnergiaEnemigo,16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFrente, barraVida);
GUI.EndGroup ();
GUI.EndGroup ();
}
}
#132
General (Antiguo) / Problema al desactivar OnGUI.
Agosto 03, 2015, 03:04:02 AM
[quote author=pioj" data-ipsquote-contapp="forums" data-ipsquote-contenttype="forums" data-ipsquote-contentclass="forums_Topic" data-ipsquote-contentid="15871" data-ipsquote-contentcommentid="101038 date=1438427211]Ahora mismo estás usando un gráfico (UI ) estático en pantalla. Sólo necesitas hacer un script que recoja ese elemento y en su lugar lo sutituya por el "elemento" que haya recibido el golpe (sea el enemigo o el player).En cualquier caso, estamos ya por la versión 5.1 de Unity, que cambia muchas cosas de la GUI. Te recomiendo que te pases al nuevo método para UI, porque de otra forma te darán problemas y errores que no puedas comprender y, menos aún, resolver.[/quote]si pero es que cambas lo he utilizado pero no solo para menús, no me encontré información relacionado con la infecciona de enemigos ademas gracias por colaborarme.
#133
General (Antiguo) / Problema al desactivar OnGUI.
Agosto 01, 2015, 05:03:57 AM
hola presento el siguiente inconveniente le acabo de añadir la barra de vida a mi enemigo funciona bien el problema que tengo es que quiero la barra de vida sea dinámica, me explico quiero que cuando golpe un enemigo cualquiera inmediatamente se muestre su nivel de vida en una parte de arriba en la barra roja, pero por ahora solo me muestra el de un enemigo a la ves y no se como desactivarla , para que se active la del enemigo que estoy atacando en ese preciso momento. Les agradecería una solución: Aquí dejo las variables relacionadas:
public GUIStyle barraVida; public Texture2D imagenFondo; public Texture2D imagenFrente; public float EnergiaEnemigo = 160f; void OnGUI()
{ GUI.BeginGroup (new Rect (10, 10, 256, 16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFondo, barraVida);
GUI.BeginGroup (new Rect (0, 0, EnergiaEnemigo,16));
GUI.Box (new Rect (0, 0, 256, 32), imagenFrente, barraVida);
GUI.EndGroup ();
GUI.EndGroup ();
}[/quote] Aca dejo un un video donde se muestra el problema.ejemplo.mp4
#134
General (Antiguo) / alternativa a NavMeshAgent.destination .
Mayo 26, 2015, 06:50:39 AM
solucion a al problema de movimiento
if(transform.localScale.x < 0)
{
rigidbody.velocity = new Vector3(0,2,0);
rigidbody.AddForce (transform.right * 200);
}
else if(transform.localScale.x > 0)
{
rigidbody.velocity = new Vector3(0,2,0);
rigidbody.AddForce (-transform.right * 200);
}
#135
General (Antiguo) / alternativa a NavMeshAgent.destination .
Mayo 26, 2015, 01:42:16 AM
bueno ya resolvi el problema pero gracias por la ayuda gente ,pero a hora tengo otro que es salta un enemigo y bueno y los demás saltan pero solo hacia arriba
no se mueven hacia los lados.
este codigo donde estoy probando el salto
no se mueven hacia los lados.
este codigo donde estoy probando el salto
else if (salto == true)
{
agent.Stop (true);
AtaqueLibiano.enabled = false;
movimientoLibiano.enabled = false;
//agent.enabled = false;
rigidbody.velocity = new Vector3 (0, -rigidbody.velocity.y, 0);
int contadorSalto = 0;
//if (contadorSalto == 0) {
//agent.updatePosition = true;
//agent.updateRotation = true;
// rigidbody.AddForce (transform.up * 200);
rigidbody.velocity = new Vector3(2,2,0);
// contadorSalto = 1;
//}
//rigidbody.velocity = new Vector3(10,10,0);
//rigidbody.AddForce(transform.up*700);
}
else if (salto == false && suelo == true)
{
agent.Stop (true);
//rigidbody.AddForce (transform.up * -100);
rigidbody.velocity = new Vector3(2,-2,0);
}
[/quote]
como haré para actualizar al enemigo es un <a data-ipb="nomediaparse" data-cke-saved-href="http://es.wikipedia.org/wiki/Beat_" rel="external nofollow">http://es.wikipedia.org/wiki/Beat_" href="http://es.wikipedia.org/wiki/Beat_" em_up"="">Beat 'em up .