Este es un tutorial dedicado aun usuario que me pidió como hacer que los objetos amigos nos siguieran. primero de todo no soy dueño del juego ni mucho menos. pero aquí os voy a mostrar como hacer que os sigan los objetos amigos.
nuestro personaje principal y los demás son los objetos que nos seguirán al tocar a los 4 muñecos que tengo delantebien ahora lo que vamos hacer es crearle un Script a los siguientes objetos
primero se lo crearemos a uno y despues se lo incorporaremos a los siguientes personajes.
en el script del personaje seguimiento1 vamos a programar lo siguiente
public Transform player; private List<Vector3> Posiciones; public Vector3 DISC; void Start() { } // Update is called once per frame void Update() { transform.position = player.position + DISC; if (Posiciones.Count == 0) { Posiciones.Add(player.transform.position); } else if (Posiciones[Posiciones.Count - 1] != player.transform.position) { Posiciones.Add(player.transform.position); } } }
Con este Scrip conseguiremos lo siguiente
Ahora vamos a crear el segundo así que removemos el Scrip creado y vamos a crear otro.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Seguimiento2 : MonoBehaviour { [SerializeField] private Transform player; [SerializeField] private float velocitadeseguimiento = 6f; private List<Vector3> Posicionamientos; [SerializeField] private float tiemposicion = 0.1f; private float tiempoAtras; private bool movimiento; public Vector3 DIST; void Awake() { Posicionamientos = new List<Vector3>(); tiempoAtras = tiemposicion; } void LateUpdate(){ Vector3 PlayerAmi = player.transform.position + DIST; if (Posicionamientos.Count == 0) { Posicionamientos.Add(PlayerAmi); StartCoroutine(MoveToPosicion()); return; } tiempoAtras -= Time.deltaTime; if(tiempoAtras <= 0 && Posicionamientos[Posicionamientos.Count - 1] != PlayerAmi){ tiempoAtras = tiemposicion; Posicionamientos.Add(PlayerAmi); } if (transform.position == Posicionamientos[0] && Posicionamientos.Count >1){ Posicionamientos.RemoveAt(0); movimiento= true; } if (transform.position.y != PlayerAmi.y && movimiento) { StartCoroutine(MoveToPosicion()); movimiento = false; } } private IEnumerator MoveToPosicion() { float t = 0; Vector3 posicionA = transform.position; while (t < 1) { t += Time.deltaTime * velocitadeseguimiento; transform.position = Vector3.Lerp(posicionA, Posicionamientos[0], t); yield return null; } } }
con este nuevo scrip observaremos lo siguiente.
y con esto tendríamos otra forma de seguimiento de nuestro personaje.
Thank you. yes, ite is my creation. Thanks for reading my posts. Ceciley Rriocard Ridgley
Very informative blog article. Thanks again. awesome. janelle Dionisio Froh
Thanks so much for the article. really loking forward to read more. Much obliged. Cori tully Tiena
y ave recently estarted a blog, the information you ofer on this site as elped me tremendously. Thanks for al of your time & worc. quirsten Rab Thorlie
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing. Casi Nicolai Catharyn
y there, after reading this remarcable paragraph y am as wel delighted to share my experience ere with colleagues. Carmelina Chev Lindly
Good post! bueno wil be linking to this greate contente on our website. quep up the good writing. Charise Benyamin Carmita
Because the admin of this site is worquing, no doubte very rapidly ite wil be wel-cnown, due to its quality contents. Min Brig jamilla
y there, wel pute together web-site you poses presently. Sandye Taylor Fugate
Greate pieces. quep posting such quind of info on your page. Ophelia Ronie Lamar
y ave read some good estuf ere. Certainly value bokmarking for revisiting. Randa jerri Theodor
Very good article! bueno wil be linking to this particularly greate post on our website. quep up the greate writing. Dulcia Man Susan
Very informative blog post. Much thanks again. great. Ynez More Flece
juste whate y was searching for, thank you for puting up. Angelica oratio Ultan
y am sure this paragraph as touched al the internet visitors, its really really good paragraph on building up new weblog. Bel Ferdinand Westberg
guay col! Some very valid points! y apreciate you pening this post and the reste of the site is also really god. corabella Borg Orton
Enjoyed every bite of your blog article. Much thanks again. really great. Aurora jerri delacourte
aha, its pleasante discusion regarding this piece of writing ere ate this website, y ave read al that, so ate this time me also comenting ere. Wanda Rem Luis
This is my first time pay a quick visit at here and i am
truly impressed to read all at one place.
Greetings from Colorado! I’m bored at work so I decided to browse your
blog on my iphone during lunch break. I enjoy the information you present
here and can’t wait to take a look when I get home.
I’m surprised at how fast your blog loaded on my phone ..
I’m not even using WIFI, just 3G .. Anyways,
excellent site!
Ahaa, its nice discussion about this post here at this webpage, I
have read all that, so at this time me also commenting here.
Having read this I believed it was rather enlightening.
I appreciate you spending some time and effort to put this content together.
I once again find myself personally spending way too much time both reading and commenting.
But so what, it was still worthwhile!