Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Want to make GameObject follow another GameObject's path Unity3D

$
0
0
Hello, I am trying to make a GameObject follow the path exactly to a player GameObject with a delay. I have looked everywhere and most scripts make the follower Lerp to the current position of the player which means it takes the shortest path rather than follow the path that the player took. So if I go around in a circle, the follower is inside the circle spinning around.
Here is the code that I am currently using: void Update() { transform.position = Vector3.Lerp(transform.position, target.position, speedPosition * Time.deltaTime); transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, speedRotation * Time.deltaTime); }
Visual of what is happening: (Red is player, Pink is path took by player;Blue is follower, light blue is path took by follower) ![alt text][1]
I want the blue path to match the pink path but be slightly behind with a delay
I plan on having a chain of followers following the same path if that helps/complicates anything
Any help is appreciated! [1]: /storage/temp/134316-question.jpg

Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>