Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Third Person Controller se mueve entorno al mundo

Iniciado por B-£otus, Abril 02, 2016, 08:13:01 PM

Tema anterior - Siguiente tema
mi personaje se mueve en dirección al mapa no a el mismo (si lo muevo hacia la derecha no se va a la derecha de el, se va a la derecha del terreno y así sucesivamente ).Saben que puedo hacer para solucionarlo??PD: Si es necesario puedo postear el script.


[quote author=GSG3D" data-ipsquote-contapp="forums" data-ipsquote-contenttype="forums" data-ipsquote-contentclass="forums_Topic" data-ipsquote-contentid="35548" data-ipsquote-contentcommentid="129039">Si, muestra el código para ver que función usas.[/quote]Este es el del Joystick:
Vector2.zero;
   }
}
Vector3 PosInicial;

void Start ()
{
   PosInicial = transform.position;
}

public void OnDrag(PointerEventData point)
{
   
   Vector2 pos;
   RectTransformUtility.ScreenPointToLocalPointInRectangle (Padre.transform as RectTransform, point.position, Padre.worldCamera, out pos);
   Vector2 newpos = Padre.transform.TransformPoint(pos) - PosInicial;
   newpos.x = Mathf.Clamp (newpos.x, -radio, radio);
   newpos.y = Mathf.Clamp (newpos.y, -radio, radio);

   Axis = newpos / radio;

   transform.localPosition = newpos;
}

public void OnEndDrag(PointerEventData point)
{
   transform.position = PosInicial;
   Axis = Vector2.zero;
}

}
Con este muevo al player (ignora las lineas comentadas):
using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour {

public Joystick S1;
//public Joystick S2;
public float velocidad = 2f;
public float velocidadAngular = 5f;
private float speed = 2.0f;


void Update ()
{
   transform.localPosition += Time.deltaTime * new Vector3 (S1.Horizontal, 0, S1.Vertical) * velocidad;
   //transform.Rotate (Vector3.up, Time.deltaTime * S2.Horizontal * velocidadAngular);
}
}


 

esas cosas pasan cuando la direccion del movimiento es global, en vez de relativa al personaje... tienes que usar el transform.forward o inversetransformdirection

Etiquetas: