Pregunta
¿Cuáles son los otros scripts para que un objeto se mueva a un objetivo?En este momento estoy usando el método Vector3.Lerp
.Esto funciona, pero el juego en movimiento se ralentiza más cerca de su objetivo.No voy a esto que suceda.Tiene que moverse directamente a la meta sin desacelerar.
Ayuda es apreciado.
Solución
One approach is just to work out the direction it should head in and then move at a constant speed in that direction:
function Update() {
var dir = target - transform.position;
dir.Normalize();
transform.position += dir * speed * Time.deltaTime;
}
You'd have to make it a little more complicated than that so that it doesn't overshoot on the final frame, but this should give you a crude approximation of what you want.
Otros consejos
You can use this function:
Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);
It should do exactly what you want.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow